Created
December 3, 2016 14:45
-
-
Save alekseytimoshchenko/993bbfcbef5f626416eed3819416232d 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
import java.io.ByteArrayOutputStream; | |
import java.io.PrintStream; | |
public class Solution { | |
public static TestString testString = new TestString(); | |
public static void main(String[] args) { | |
PrintStream consoleStriam = System.out; | |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | |
PrintStream stream = new PrintStream(baos); | |
System.setOut(stream); | |
testString.printSomething(); | |
String result = baos.toString(); | |
System.setOut(consoleStriam); | |
System.out.println(result.replaceAll("te", "??")); | |
} | |
public static class TestString { | |
public void printSomething() { | |
System.out.println("it's a text for testing"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment