0

I have looked through some questions of the similar name, none yielding the desired results. Here's an overview of my issue.

I use both println() and print() statements for Notepad++, and the console is System.out. I tried working with System.out.flush(), but I don't believe it is the function that I am looking for.

My main objective is to delete all the previous printed information, so updated information can be reprinted in its stead. I seen some solutions like

for(int i = 0; i < 50; i++)
    {
        System.out.println("\n");
    }

but that didn't take into account the size of the console, which could vary by computer and by user adjusted sizes.

Thus, the most effective way is to somehow delete the code. I looked into Runtime and "cls", along with many of the other various methods (ANSI) that were offered in other solutions, which makes me believe that using Notepad++ has its own unique ways of clearing the console.

Another unforeseen possibility is that there is some way to update the displayed String, in which case knowing how to do that would be very helpful. As far as I know, there's no way of doing so.

Any help is appreciated!

ArQane - ArQ
  • 45
  • 1
  • 10

1 Answers1

0

Simple solution:

new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();

Note: Only works for CMD If you use IDE then not, Because command cls is of Windows command prompt and IDE is not command prompt and even if you use Linux OS or some other the Windows OS then also it was not work.

Sunil Kanzar
  • 1,244
  • 1
  • 9
  • 21