Through the following code, I can execute and get the shell command, and get the output, but only after the end of the process, can I get the standard output. How can I get the real-time output when the process is executing
Process process = Runtime.getRuntime().exec(command);
// close process's output stream.
process.getOutputStream().close();
pIn = process.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(pin, "UTF-8");
bufferedReader = new BufferedReader(inputStreamReader);
String line = null;
while ((line = bufferedReader.readLine()) != null) {
this.buf.append(line + "\n");
}
process.waitfor();