I created a sample Java application. I want to clear the window options, i.e.:
- Register
- Login
- Clear
If the user presses 3 I need to programmatically clear all options. Something like Console.clear
?
Is there any way that I can do this with Java?
I created a sample Java application. I want to clear the window options, i.e.:
If the user presses 3 I need to programmatically clear all options. Something like Console.clear
?
Is there any way that I can do this with Java?
You will need to output a bunch of blank lines. Even in Windows/*nix, clear/cls doesn't truly clear the screen, it just prints enough blank lines that you cannot see the previous text.
You can try System.out.print("CLS");
Or use loops to clear the screen like
public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
and then call this method clearScreen(); if you want to clear.
Sorry my english is bad. :) I just want to help you.
If you are working with the console, then these might prove useful. Using "backspace" character. Using process builder.
You mean you created a console application and want to clear the console (not necessarily the Eclipse console)?
If so then I guess you're looking for:
Runtime.getRuntime().exec("cls");
But be aware this will be system dependent.