On Linux, there are various escape sequences for the control terminal. For example, there is a special escape sequence to erase the entire line: \33[2K and to move the cursor to the previous line: \33[1A . So all you need to do is print this every time you need to update a line. Here is the code that prints Line 1 (second variant) :
System.out.println("Line 1 (first variant)"); System.out.print("\33[1A\33[2K"); System.out.println("Line 1 (second variant)");
There are codes for cursor navigation, cleaning screen, etc.
I think there are some libraries that help with it ( ncurses ?).
Kirill Oct 29 '11 at 15:45 2011-10-29 15:45
source share