Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alekseytimoshchenko/993bbfcbef5f626416eed3819416232d to your computer and use it in GitHub Desktop.
Save alekseytimoshchenko/993bbfcbef5f626416eed3819416232d to your computer and use it in GitHub Desktop.
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