Created
September 7, 2011 03:27
-
-
Save gtrak/1199683 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReadStdout implements Runnable { | |
BufferedReader pipe; | |
Process process; | |
private Poster poster; | |
public ReadStdout(Process p) { | |
process = p; | |
} | |
public void post(String s){ | |
poster.post(s); | |
} | |
public void run() { | |
pipe = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
try { | |
while(true) { | |
post(pipe.readLine()); | |
Thread.sleep(200); | |
} | |
} | |
catch(InterruptedException e) { | |
System.out.println(e.getMessage()); | |
e.printStackTrace(); | |
} catch(IOException e) { | |
System.out.println(e.getMessage()); | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment