Below is my code to read the output from console. I need to read the tracert path live to console.
Below code prints the data at once after finishing the process only.
Can someone help me?
ProcessBuilder f = new ProcessBuilder("cmd.exe","tracert ip_address");
Process p = f.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader readers = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String lines =null;
System.out.println();
while((lines = reader.readLine())!=null) {
System.out.println("lines:"+lines);
}
String lines1 =null;
while((lines1 = readers.readLine())!=null) {
System.out.println("error lines:"+lines1);
}