I am trying to search the word "hop"
from the traceroute output, but somehow its not displaying that line on console. Please let me know where I am going wrong.
Here is my code:
import java.io.*;
public class TestExec {
public static void main(String[] args) {
try {
String[] cmdarray = { "nmap", "--traceroute", "nmap.org" };
Process p = Runtime.getRuntime().exec(cmdarray);
BufferedReader in = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
if (line.contains("hop")) {
System.out.println(line);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}