-2

I'm writing a text-based unit converter and I want to be able to run a clear command so that the window that the program I want to know how I can do it.

SamGreenwood
  • 19
  • 1
  • 5
  • Just make some `System.out.println()`'s. I don't think there is a native method to clear the terminal and no OS-independent way either. – Turing85 Nov 14 '17 at 20:04
  • To clear BlueJ output window each time the program start, just add this statement at first line of the main method: System.out.print('\u000C'); – Ruslan Skaldin May 04 '21 at 10:01

1 Answers1

0

I think you can System.exec("clear") but that depends on what operating system the program is running on.

This is my choice for clear:

public static void clearConsole() {
        String value = "\n\r";
        for (int i = 0; i < 5; ++i) {
            value = value + value;
            System.out.printf(value);
        }
    }
Sam Orozco
  • 1,258
  • 1
  • 13
  • 27