Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created April 9, 2014 00:51
Show Gist options
  • Save trikitrok/9d39f6a5782f792a7036 to your computer and use it in GitHub Desktop.
Save trikitrok/9d39f6a5782f792a7036 to your computer and use it in GitHub Desktop.
package com.adaptionsoft.games.trivia;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
public class StandardOutputRedirection {
private ByteArrayOutputStream newOut;
private PrintStream old_out;
public StandardOutputRedirection(
ByteArrayOutputStream newOut,
PrintStream old_out) {
super();
this.newOut = newOut;
this.old_out = old_out;
System.setOut(new PrintStream(this.newOut));
}
public void reset() {
System.setOut(old_out);
}
public String getRedirectedOutput() {
return new String(newOut.toByteArray());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment