Код: Выделить всё
getFilesThreadКод: Выделить всё
private static class ClearCaseProcess {
private ArrayList stdout = new ArrayList();
private ArrayList stderr = new ArrayList();
private ProcessBuilder pb = null;
public ClearCaseProcess(ArrayList commands, String dir) throws IOException {
pb = new ProcessBuilder(commands);
pb.directory(new File(dir));
}
public void start() throws IOException {
long minStart = System.nanoTime();
Process process = pb.start();
Thread sout = new Thread() {
@Override
public void run() {
BufferedReader out = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String outLine = "";
try {
while ((outLine = out.readLine()) != null) {
stdout.add(outLine);
System.out.println(outLine);
}
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
}
};
sout.start();
Thread serr = new Thread() {
@Override
public void run() {
BufferedReader err = new BufferedReader(
new InputStreamReader(process.getErrorStream()));
String errLine = "";
try {
while ((errLine = err.readLine()) != null) {
stderr.add(errLine);
System.err.println(errLine);
}
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
}
};
serr.start();
try {
process.waitFor();
long execTime = System.nanoTime() - minStart;
System.out.println("Process '" + description + "' took " + execTime);
} catch (InterruptedException ex) {
System.err.println(ex.getMessage());
}
}
}
< /code>
getFiles()Подробнее здесь: https://stackoverflow.com/questions/425 ... in-a-termi