Created
April 19, 2013 06:34
-
-
Save bleach/5418528 to your computer and use it in GitHub Desktop.
jruby gethostname implementation
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
gdb@tyler:~$ javac HostnameTest.java | |
gdb@tyler:~$ java HostnameTest | |
0.0.0.0 | |
gdb@tyler:~$ java -version | |
java version "1.7.0_21" | |
Java(TM) SE Runtime Environment (build 1.7.0_21-b11) | |
Java HotSpot(TM) Server VM (build 23.21-b01, mixed mode) |
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 HostnameTest { | |
public static void main(String[] args) { | |
try { | |
System.out.println(InetAddress.getByAddress(new byte[]{0,0,0,0}).getHostName()); | |
} catch (UnknownHostException e2) { | |
System.out.println("Caught UnknownHostException"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment