Skip to content

Instantly share code, notes, and snippets.

@bleach
Created April 19, 2013 06:34
Show Gist options
  • Save bleach/5418528 to your computer and use it in GitHub Desktop.
Save bleach/5418528 to your computer and use it in GitHub Desktop.
jruby gethostname implementation
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)
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