I'm executing this command in order to open the log file with default file viewer:
Process p = Runtime.getRuntime().exec("rundll32 url.dll, FileProtocolHandler F:/Download/MSI3ca79.LOG");
I would like to know when the file is closed. Is it possible?
p.waitFor(); // doesn't work because the process is terminated just after the execution.
Solution:
ProcessBuilder pb =
new ProcessBuilder("c:/windows/notepad.exe", "F:/Download/MSI3ca79.LOG");
File log = new File(LogFactory.getLogFactory(TestExternProcess.class).getName()); pb.redirectErrorStream(true);
pb.redirectOutput(Redirect.appendTo(log));
Process p = pb.start();
int exitVal = p.waitFor();