-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExHost.java
33 lines (32 loc) · 1.04 KB
/
ExHost.java
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
/**
* @author Arm
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.*;
public class ExHost {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
String strLine = "";
try {
BufferedReader br = new BufferedReader(new FileReader("C:/host.txt"));
while(strLine != null){
if(strLine == null) break;
// System.out.println(strLine);
try {
if(strLine!=""){
InetAddress IPad = InetAddress.getByName(strLine);
System.out.printf("%s : %s\n",strLine,IPad.getHostAddress());
}
} catch (UnknownHostException e) {
System.out.printf("%s : unknown host\n",strLine);
}
strLine = br.readLine();
}
br.close();
} catch (IOException e) {
System.out.println("file not found!");
}
}
}