I have a Java program that executes Runtime.getRuntime().exec(\"ls -l\"); many times, once for each directory in the system.
My test system has more than 1,000 direc
You should explicitly close the input/output streams when using Runtime.getRuntime().exec
.
Process p = null;
try {
p = Runtime.getRuntime().exec("ls -l");
//process output here
p.waitFor();
} finally {
if (p != null) {
p.getOutputStream().close();
p.getInputStream().close();
p.getErrorStream().close();
}
}