Demo 4/7
berikut adalah source code untuk melihat network name dan host name pada komputer.
import java.net.*;
public class NsLookup {
public static void main(String args[]) {
if (args.length == 0) {
System.out.println("Pemakaian: java NsLookup");
System.exit(0);
}
String host = args[0];
InetAddress address = null;
try {
address = InetAddress.getByName(host);
} catch(UnknownHostException e) {
System.out.println("Unknown host");
}
byte[] ip = address.getAddress();
for (int i=0; i if (i > 0) System.out.print(".");
System.out.print((ip[i]) & 0xff);
}
System.out.println();
}
}
berikut adalah source code untuk melihat network name dan host name pada komputer.
import java.net.*;
public class NsLookup {
public static void main(String args[]) {
if (args.length == 0) {
System.out.println("Pemakaian: java NsLookup
System.exit(0);
}
String host = args[0];
InetAddress address = null;
try {
address = InetAddress.getByName(host);
} catch(UnknownHostException e) {
System.out.println("Unknown host");
}
byte[] ip = address.getAddress();
for (int i=0; i
System.out.print((ip[i]) & 0xff);
}
System.out.println();
}
}
Tidak ada komentar:
Posting Komentar