-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathipaddress.java
More file actions
24 lines (19 loc) · 763 Bytes
/
ipaddress.java
File metadata and controls
24 lines (19 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.*;
import java.net.*;
import javax.print.event.PrintJobListener;
public class ipaddress {
public static void main(String[] args) {
try {
InetAddress ip = InetAddress.getByName("www.packtpub.com");
System.out.println(ip);
System.out.println("Cannonical Host Name: " + ip.getCanonicalHostName());
System.out.println("IP Address: " + ip.getHostAddress());
System.out.println("Host Name: " + ip.getHostName());
}
catch (Exception e) {
System.out.println(e);
}
}
}
// The host name is the real name the server has. A canonical name is a name
// that the host is known by, but that the host is not actually called.