Currently, my program prints to System.out
:
Processing line 1 of 3...
Processing line 2 of 3...
Processing line 3 of 3...
Is there any way to have it replace the line numbers, instead of printing a new line?
Currently, my program prints to System.out
:
Processing line 1 of 3...
Processing line 2 of 3...
Processing line 3 of 3...
Is there any way to have it replace the line numbers, instead of printing a new line?
Well there are some hacks you can try, but none of them are guaranteed to work everywhere. Escape characters such as \b
(backspace) can erase the last character and \r
(replace) can erase the last output.
It may or may not work (depending on IDE), but you could try:
System.out.print("Hello");
Thread.sleep(1000);
System.out.print("\rWorld");
However, generally a Swing box should be used (dynamically updating GUI) to measure progress. See Progress Bars.