import java.net.InetAddress; import java.net.UnknownHostException; public class IPtoDNS { /** * Find the DNS name associated with an IP * * @param args not used */ public static void main ( String[] args ) { try { InetAddress[] addresses = InetAddress.getAllByName( "24.69.120.20" /* ip or DNS name */ ); for ( int i=0; i<addresses.length; i++ ) { String hostname = addresses[i].getHostName(); out.println( hostname ); } } catch ( UnknownHostException e ) { out.println( "unknown host" ); } } }