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.
Asked
Active
Viewed 742 times
0
-
2What have you tried so far? Could you clarify please? – easythrees Nov 16 '18 at 22:59
1 Answers
1
"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
- 114,292
- 17
- 138
- 190
-
3
-
@Li357 - whoops! Thank you for pointing out that I copied/pasted the wrong URL. I updated the post with the correct one - and also included the example code. – paulsm4 Nov 16 '18 at 23:51
-
-