Return Line in Windows / Java

Is there a way to write multiple lines on the system console in Windows and then delete or modify them using Java? I can write the same line more than once using the carriage return character \r . The Cygwin less command (text viewer) manages it (although this is not Java), so I suspect it is possible.

I tried \u008D , which (according to the page I googled) has a reverse line character, but it doesn't seem to work.

  System.out.println("1"); System.out.println("2"); System.out.print("\u008D"); System.out.println("3"); 

exits

 1 2 ?3 

whereas I was hoping to see

 1 3 
+4
source share
2 answers

Try System.out.print("\b"); It does not work in eclipse ( bug - source ), but should work differently.

+1
source

The JLine library can provide more advanced console control if nothing works. Keep in mind that it uses native code.

The killLine () method may be what you need if you end up using JLine.

+1
source

All Articles