The Java console outputs a percentage progress bar example
- 2020-04-01 03:17:07
- OfStack
System.out.print("\b") will delete one character back in the console, and if you want to delete more than one character, print more than one "\b"
public static void main(String[] args) throws Exception {
System.out.print("Progress:");
for (int i = 1; i <= 100; i++) {
System.out.print(i + "%");
Thread.sleep(100);
for (int j = 0; j <= String.valueOf(i).length(); j++) {
System.out.print("b");
}
}
System.out.println();
}