display percentage in java console
package org.kodejava.example.lang;
public class ConsoleProgressBar {
public static void main(String[] args) {
char[] animationChars = new char[]{'|', '/', '-', '\\'};
for (int i = 0; i <= 100; i++) {
System.out.print("Processing: " + i + "% " + animationChars[i % 4] + "\r");
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Processing: Done! ");
}
}