| | |
| | | import java.io.FileReader; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.nio.file.Files; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | try |
| | | { |
| | | process = processBuilder.start(); |
| | | final BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream())); |
| | | new OutputReader(err) |
| | | new OutputReader(process.getErrorStream()) |
| | | { |
| | | @Override |
| | | public void processLine(final String line) |
| | |
| | | } |
| | | }.start(); |
| | | |
| | | final BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | new OutputReader(out) |
| | | new OutputReader(process.getInputStream()) |
| | | { |
| | | @Override |
| | | public void processLine(final String line) |
| | |
| | | { |
| | | if (process != null) |
| | | { |
| | | closeProcessStream(process.getErrorStream(), "error"); |
| | | closeProcessStream(process.getOutputStream(), "output"); |
| | | // The error and output streams of the process are owned by the readers started above, |
| | | // which close them once drained. Only the stream writing to the standard input of the |
| | | // process, which is never used here, is left to close. |
| | | closeProcessStream(process.getOutputStream(), "input"); |
| | | } |
| | | } |
| | | } |