+ 1
How to clear console screen in Java?
Its possible in C++ but, I want to clear console screen in Java. Is it possible, if yes how?.
3 Answers
+ 5
Android terminals respond to ANSI escape sequences. To clear the screen, print:
chr(27) + "[2J"
then put the cursor at 0,0 by printing:
chr(27) + "[0;0H"
You may combine those into one string.
+ 1
Though there is no such support on Java. But other way round by calling relevant OS command like cls or clear
if( System.getProperty( "os.name" ).startsWith( "Window" ) ) {
Runtime.getRuntime().exec("cls"); //Windows os
} else {
Runtime.getRuntime().exec("clear"); //Linux based
}
+ 1
@Decender Mahajan that's doesn't goona work for me as I am using AIDE JAVA COMPILER in Android. Still Thanks