You can override system.out (I believe this is System.setOut ()) I believe that you can set it to NULL (fixed - you cannot set it to NULL), but you can set it to ANY output stream.
I did something interesting with this once. I saved "System.out" and then redirected it to my own output stream with the code in the "print" method - this method is called whenever someone prints on the stream.
, , , , System.out.println(). - โโ .
, , , .
, . , , , "BK:", .
.
( , , )
public static final OutputStream out;
{
out=System.getOutputStream();
System.setOutputStream(new OutputStreamThatDoesNothing());
}
:
Redirect.out("Hello");
, System.out.
, - , :
OutputStream tmp=System.getOutputStream();
System.setOutpuatStream(nullStream);
callOffensiveLibraryMethod();
System.setOutputStream(tmp);
, , .