does this code work to clear the console screen in java
System.out.print("\033[H\033[2J");
System.out.flush();
does this code work to clear the console screen in java
System.out.print("\033[H\033[2J");
System.out.flush();
Having just tested it in a blank Java repl, yes it does.
yes, I can explain. Basically Ansi codes are things you can print to the console that get intrepted. For example, if you have \n
it gets interpreted as a newline. In linux, those codes are interpreted as so:
\033
is the start is ansi codes[H
allows you to move the cursor to some x, y coordinate with it moving to the beginning as default – otherwise you can do 033[1;1H
)\033[2J
hope this helped
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.