Skip to content

Instantly share code, notes, and snippets.

@hardyscc
Last active August 12, 2024 14:50
Show Gist options
  • Save hardyscc/ad6badbdf669a063920f7f7f48ad2880 to your computer and use it in GitHub Desktop.
Save hardyscc/ad6badbdf669a063920f7f7f48ad2880 to your computer and use it in GitHub Desktop.
HostnameFromIp.java
echo "import java.net.InetAddress; \
public class HostnameFromIp { \
    public static void main(String[] args) throws Exception { \
        var startTime = System.currentTimeMillis(); \
        System.out.println(InetAddress.getByName(args[0]).getHostName() + \
                \" - \" + (System.currentTimeMillis() - startTime) + \"ms\"); \
    } \
}" > HostnameFromIp.java

javac HostnameFromIp.java
java HostnameFromIp 8.8.8.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment