Guest User

Untitled

a guest
Nov 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public String exec(String command) {
  2. String line, output = "";
  3. try {
  4. ProcessBuilder builder = new ProcessBuilder(command.split(" "));
  5. Process process = builder.start();
  6.  
  7. BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
  8.  
  9. while ((line = br.readLine()) != null) {
  10. System.out.println(line);
  11. output += line + "n";
  12. }
  13. } catch (IOException e) { e.printStackTrace(); }
  14. return output;
  15. }
Add Comment
Please, Sign In to add comment