I\'m using a java library (jar file). The author of the file put in a bunch of System.out.print
and System.out.println
s. Is there any way to hide these
Change original PrintStream with a Dummy one which does nothing on it's write()
method.
Don't forget to replace original PrintStream when you finished.
System.out.println("NOW YOU CAN SEE ME");
PrintStream originalStream = System.out;
PrintStream dummyStream = new PrintStream(new OutputStream(){
public void write(int b) {
// NO-OP
}
});
System.setOut(dummyStream);
System.out.println("NOW YOU CAN NOT");
System.setOut(originalStream);
System.out.println("NOW YOU CAN SEE ME AGAIN");