Working in console with Java

0

What I want to do is basically that anterior impreso en consola se borre , that is, if for example I write a program that prints a "Hola mundo" in the console, that the next instruction after System.out.println("Hola mundo"); is an instruction that erases the above written, which would be in this case the hola mundo .

    
asked by Cokóro R1 21.06.2017 в 02:59
source

2 answers

0

Add many blank lines with a for before the new instruction.

for(int i=0;i<8;i++){ System.out.println(""); } That may be a solution to your problem.

    
answered by 21.06.2017 в 07:54
0

The problem is that JAVA does not have an instruction to erase the console. You can print the character backspace that in unicode is 0008 but that only works for the current line. For example:

System.out.println("hola mundo\u0008");

That only prints hola mund however it does not work for the lines that are already printed before the \n . Even trying to call the shell clear Runtime.getRuntime().exec("clear"); does not work.

I hope you find it useful, but I think the solution is the one that says @Hezu Jared.

    
answered by 21.06.2017 в 14:05