Created
April 9, 2014 00:51
-
-
Save trikitrok/9d39f6a5782f792a7036 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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