Skip to content

Instantly share code, notes, and snippets.

@shulhi
Created July 22, 2014 03:22
Show Gist options
  • Save shulhi/dec97643eff7eb43f020 to your computer and use it in GitHub Desktop.
Save shulhi/dec97643eff7eb43f020 to your computer and use it in GitHub Desktop.
check hostname
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