Use BufferedReader.lines()

Closes gh-11436
This commit is contained in:
Johnny Lim
2017-12-27 14:36:38 +09:00
committed by Stephane Nicoll
parent 50a4982a52
commit 8f7ab95e0e
6 changed files with 19 additions and 57 deletions

View File

@@ -147,17 +147,13 @@ public class RunProcess {
}
private void redirectOutput(Process process) {
final BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
new Thread(() -> {
try {
String line = reader.readLine();
while (line != null) {
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()))) {
reader.lines().forEach((line) -> {
System.out.println(line);
line = reader.readLine();
System.out.flush();
}
reader.close();
});
}
catch (Exception ex) {
// Ignore