private String readOutput(final Process p) throws IOException {
try {
StringWriter output = new StringWriter();
final PrintWriter ps = new PrintWriter(output);
Thread stderrThread = new Thread(new StreamConsumer("STDERR", p.getErrorStream(), ps));
Thread stdoutThread = new Thread(new StreamConsumer("STDOUT", p.getInputStream(), ps));
p.getOutputStream().close();
stderrThread.start();
stdoutThread.start();
stderrThread.join();
stdoutThread.join();