Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String command(String cmd) throws Exception {
- String out = "";
- Runtime runtime = Runtime.getRuntime();
- process proc = runtime.exec(cmd);
- proc.waitFor();
- InputStream is = proc.getInputStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- String line;
- while ((line = br.readLine()) != null) {
- System.out.println(line);
- if (!out.equals(""))
- out += '\n';
- System.out.println(line);
- out += line;
- }
- if(proc.exitValue() == 1)
- throw exErrorOne;
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement