Skip to content

Instantly share code, notes, and snippets.

@orls
Created April 23, 2012 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orls/2471268 to your computer and use it in GitHub Desktop.
Save orls/2471268 to your computer and use it in GitHub Desktop.
import java.net.InetSocketAddress;
public class TestDns {
public static void main(String[] args) {
System.out.println(sun.net.InetAddressCachePolicy.get());
InetSocketAddress unresolved = InetSocketAddress.createUnresolved("10.228.174.223", 8020);
System.out.println(unresolved.toString()); // prints 10.228.174.223:8020
System.out.println(unresolved.getHostName()); // prints 10.228.174.223:8020
System.out.println(unresolved.toString()); // prints 10.228.174.223:8020
InetSocketAddress resolved = new InetSocketAddress("10.228.174.223", 8020);
System.out.println(resolved.toString()); // prints /10.228.174.223:8020
System.out.println(resolved.getHostName()); // prints ip-10-228-174-223.eu-west-1.compute.interna
System.out.println(resolved.toString()); // prints ip-10-228-174-223.eu-west-1.compute.interna/10.228.174.223:8020
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment