Skip to content

Instantly share code, notes, and snippets.

@colin-haber
Created May 27, 2011 02:56
Show Gist options
  • Save colin-haber/994558 to your computer and use it in GitHub Desktop.
Save colin-haber/994558 to your computer and use it in GitHub Desktop.
JavaCon Error Stream handling
Thread t = null;
try {
final PipedOutputStream errOut = new PipedOutputStream();
System.setErr(new PrintStream(errOut));
final BufferedReader errIn = new BufferedReader(new InputStreamReader(new PipedInputStream(errOut)));
t = new Thread(
new Runnable() {
public void run() {
try {
this.wait();
while (true) {
String error = errIn.readLine();
print(error);
}
} catch (IOException e){
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
, "ERROR");
t.start();
} catch (Exception e) {
}
//GUI creation
t.notify();
@colin-haber
Copy link
Author

Does this work for anyone else? I'm having problems actually creating errors. They only show up on the JavaCon every once in a while. And I guarantee, I have enough cores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment