+ 5
Clear screen In Java
how can I clear screen in Java? Just like clrscr(); in C language
7 Réponses
+ 12
System.out.print('\f');
or
System.out.print('\u000C');
+ 11
You can use ANSI escape control sequence:
System.out.print("\u001B[2J");
... will clear the screen ( without replacing text cursor at top left corner ^^ )
This should work on console ( real local ) but not with the console output emulator of Slolearn code playground :(
[ edit ]
https://en.m.wikipedia.org/wiki/ANSI_escape_code
+ 8
That doesn't work if you use your console to run your program. Works in ide.
+ 5
I just needed this in Python*, and ANSI clear does not home the cursor to (0,0); it just prints enough blank lines to clear content...continuing at the bottom:
[ (cleared area)
[
[
[ content prints at bottom
[ scrolling up_
The entire ANSI command string should be:
chr(27) + "[2J" + chr(27) + "[0;0H"
This clears the screen (2J) and positions the print cursor at the top left (0;0H) so it prints downwards.
* (not Windows. Printing chr(12) usually clears those terminals)
+ 4
not working :(
+ 4
okk
0
Tashi n fuck u when you dont know anything then why you post anything you motherfucking piece of shit . piece of cow dung.Just imagine if your dad used a condem and you were not even born. This earth would have been very peaceful you whore