Created
June 9, 2011 14:38
-
-
Save freynaud/1016852 to your computer and use it in GitHub Desktop.
ghghg
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
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