Is there any way to wipe the screen without cycling with ' n' ?

Asked

Viewed 36 times

1

I would like to know if there are other possibilities besides for example executing a series of ' n'.

public void clrscrn(){
    for (int i = 0; i < 50; ++i) 
        System.out.println();
}

1 answer

1


Two possibilities I know:

final String sisOpe = System.getProperty("os.name");

if (sisOpe.contains("Windows")){
    Runtime.getRuntime().exec("cls");

}else{
    Runtime.getRuntime().exec("clear");
}

or

System.out.print("\u001b[2J");
System.out.flush();
  • Advantages and disadvantages of each ?

  • I honestly don’t know Jorge. But I heard about the first being very ugly. Perhaps by invoking a cmd command.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.