0

I would like to know if it is possible in Java to hide all Console-Print-Outs for a certain amount of lines or time.

Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420
51m0n
  • 13
  • 2

1 Answers1

0

"Java console output" is actually written to java.System.out.

If you wanted to "stop output" for some period, you could could temporarily "redirect" System.out to a dummy stream; some stream that doesn't write anything.

Look here: Hiding System.out.print calls of a class

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");
paulsm4
  • 107,438
  • 16
  • 129
  • 179