-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWhois.java
More file actions
45 lines (26 loc) · 754 Bytes
/
Whois.java
File metadata and controls
45 lines (26 loc) · 754 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
37
38
39
40
41
42
43
44
45
import java.util.*;
import java.io.*;
public class Whois extends Main {
public String whois_ops(String url) {
String n_url = url.substring(4);
String command = "whois " + n_url;
String whois_results = executeCommand(command);
return whois_results;
}
public String executeCommand(String command) {
StringBuffer whois_results = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(command);
p.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!=null) {
whois_results.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return whois_results.toString();
}
}