I have a java application which run on cmd. I want to show progress while running this process. In this application 50 branches processing and I want to show after processed one branch 2% completed and after another branch processed 4% completed and so on.
Problem is when I used
System.out.print("PROGRESS :" + branch_Vec.get(value).toString()+" : "+ df2.format(((a / total) * 100)) +" % \r");
as a out put it goes to new line each time it calls.
I want to show progress in same line.For example:
progress : AB : 2%
The code System.out.print("\rComplete: "+percentage); should just work.
The \r is a carriage return, and will clear the current line. As long as you don't write a newline \n you can update the text.
Note that this does not work in the console in Eclipse, if you're using that to test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With