Skip to content

Instantly share code, notes, and snippets.

@gtrak
Created September 7, 2011 03:27
Show Gist options
  • Save gtrak/1199683 to your computer and use it in GitHub Desktop.
Save gtrak/1199683 to your computer and use it in GitHub Desktop.
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