Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.net.*;
  2. public class NsLookup {
  3. public static void main(String args[]) {
  4. if (args.length == 0) {
  5. System.out.println("Pemakaian: java NsLookup <hostname>");
  6. System.exit(0);
  7. }
  8. String host = args[0];
  9. InetAddress address = null;
  10. try {
  11. address = InetAddress.getByName(host);
  12. } catch(UnknownHostException e) {
  13. System.out.println("Unknown host");
  14. System.exit(0);
  15. }
  16. byte[] ip = address.getAddress();
  17. for (int i=0; i<ip.length; i++) {
  18. if (i > 0) System.out.print(".");
  19. System.out.print((ip[i]) & 0xff);
  20. }
  21. System.out.println();
  22. }
  23. }