Created
July 22, 2014 03:22
-
-
Save shulhi/dec97643eff7eb43f020 to your computer and use it in GitHub Desktop.
check hostname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
public class dns { | |
public static void main(String[] args) throws UnknownHostException { | |
InetAddress addr = InetAddress.getLocalHost(); | |
System.out.println(String.format( | |
"IP:%s hostname:%s canonicalName:%s", | |
addr.getHostAddress(), | |
addr.getHostName(), | |
addr.getCanonicalHostName() | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment