All pastes #968048 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-02 20:11 UTC
rendered paste body
import java.net.*;

public class Lookup {

    public static void main(String[] args) {
	InetAddress addr = null;

	if (args.length!=1) {
	    System.out.println("Syntax: java Lookup <hostname>");
	    System.exit(1);
	}
	try {
	    addr = InetAddress.getByName(args[0]);
	} catch(UnknownHostException e) {
	    System.out.println("Unknown host name: "+args[0]);
	    System.exit(1);
	}
	String hostname = addr.getHostName();
	String address = addr.getHostAddress();
	System.out.println("Host name:        "+hostname);
	System.out.println("Internet address: "+address);
    }

}