Skip to content

Instantly share code, notes, and snippets.

@freynaud
Created June 9, 2011 14:38
Show Gist options
  • Save freynaud/1016852 to your computer and use it in GitHub Desktop.
Save freynaud/1016852 to your computer and use it in GitHub Desktop.
ghghg
public class IPTroubleShoot {
public static void main(String[] args) {
current();
test();
}
public static void current() {
InetAddress addr;
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw new InstantiationError("cannot find hub ip");
}
String host = addr.getHostAddress();
System.out.println("current : " + host);
}
public static void test() {
NetworkUtils utils = new NetworkUtils();
String s = utils.getIp4NonLoopbackAddressOfThisMachine().getHostAddress();
System.out.println("test : " + s);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment