int len = stdout.read(buffer);
if (len > 0) // this check is somewhat paranoid
System.out.write(buffer, 0, len);
}
while (stderr.available() > 0)
{
int len = stderr.read(buffer);
if (len > 0) // this check is somewhat paranoid
System.err.write(buffer, 0, len);
}