0

Is there any ways to save the final output from command prompt to a text file after the program finished running? I have tried it with ProcessBuilder and it does not work. (Reason because my output does not appear immediately, it goes through a short processing time before the output is loaded onto the command prompt screen) in java.

String command = "cmd /c start cmd /k E:\\vol231.exe -f E:\\KOHMOHOJOJO-PC-20140714-152414.raw imageinfo > output.txt";
Process p = Runtime.getRuntime().exec(command);

enter image description here enter image description here

It actually takes around 2-5 mins for it to process.

I referred to several websites but it still does not work. Any help given will be greatly appreciated.

Steven
  • 107
  • 2
  • 14

1 Answers1

0

You can try save output with java code:

StringWriter writer = new StringWriter();
IOUtils.copy(p.getInputStream(), writer, encoding);
String theString = writer.toString();

Also error stream can be saved with class "ProcessBuilder"

pasha701
  • 6,831
  • 1
  • 15
  • 22