private static String exec(String... args) { ByteArrayOutputStream err = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { Process p = Runtime.getRuntime().exec(args); copyInThread(p.getInputStream(), out); copyInThread(p.getErrorStream(), err); p.waitFor(); String e = new String(err.toByteArray(), "UTF-8"); if (e.length() > 0) { throw new RuntimeException(e); } String output = new String(out.toByteArray(), "UTF-8"); return output; } catch (Exception e) { throw new RuntimeException(e); } }
private static String exec(String... args) { ByteArrayOutputStream err = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { Process p = Runtime.getRuntime().exec(args); copyInThread(p.getInputStream(), out); copyInThread(p.getErrorStream(), err); p.waitFor(); String e = new String(err.toByteArray(), "UTF-8"); if (e.length() > 0) { throw new RuntimeException(e); } String output = new String(out.toByteArray(), "UTF-8"); return output; } catch (Exception e) { throw new RuntimeException(e); } }
private static String exec(String... args) { ByteArrayOutputStream err = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { Process p = Runtime.getRuntime().exec(args); copyInThread(p.getInputStream(), out); copyInThread(p.getErrorStream(), err); p.waitFor(); String e = new String(err.toByteArray(), "UTF-8"); if (e.length() > 0) { throw new RuntimeException(e); } String output = new String(out.toByteArray(), "UTF-8"); return output; } catch (Exception e) { throw new RuntimeException(e); } }