-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreverse.java
More file actions
36 lines (30 loc) · 869 Bytes
/
reverse.java
File metadata and controls
36 lines (30 loc) · 869 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
25
26
27
28
29
30
31
32
33
34
35
36
import java.net.*;
import java.lang.String;
//Name: Jakob Millen
//ID: 1507831
class reverse
{
public static void main(String[] args)
{
if (args.length == 0) {
System.err.println("Error: No ip provided");
return;
}
for (String ip : args) {
InetAddress ia;
String name;
try {
ia = InetAddress.getByName(ip);
name = ia.getHostName();
} catch (UnknownHostException e) {
System.err.println("Unknown Host: " + ip);
continue;
}
int result = ip.compareTo(name);
if(result == 0){
name = "no name";
}
System.out.println("IP Address: " + ip + " Name: " + name);
}
}
}