-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInet_address.java
More file actions
46 lines (35 loc) · 1.07 KB
/
Inet_address.java
File metadata and controls
46 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package network;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Inet_address {
public static void main(String[] args) {
// TODO Auto-generated method stub
InetAddress ip1;
try {
ip1 = InetAddress.getByName("www.javatpoint.com");
System.out.println(ip1.getHostAddress());
System.out.println(ip1.getHostName());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InetAddress ip2;
try {
ip2 = InetAddress.getByName("https://www.youtube.com/");
System.out.println(ip2.getHostAddress());
System.out.println(ip2.getHostName());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InetAddress ip3;
try {
ip3 = InetAddress.getByName("https://mail.google.com/mail/u/0/");
System.out.println(ip3.getHostAddress());
System.out.println(ip3.getHostName());
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}