Guest User

Untitled

a guest
Jan 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. public class ReadStdout implements Runnable {
  2.  
  3. BufferedReader pipe;
  4. Process process;
  5. private Poster poster;
  6.  
  7. public ReadStdout(Process p) {
  8. process = p;
  9. }
  10.  
  11. public void post(String s){
  12. poster.post(s);
  13. }
  14.  
  15. public void run() {
  16. pipe = new BufferedReader(new InputStreamReader(process.getInputStream()));
  17. try {
  18. while(true) {
  19. post(pipe.readLine());
  20. Thread.sleep(200);
  21. }
  22. }
  23. catch(InterruptedException e) {
  24. System.out.println(e.getMessage());
  25. e.printStackTrace();
  26. } catch(IOException e) {
  27. System.out.println(e.getMessage());
  28. e.printStackTrace();
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment