display percentage in java console

Solutions on MaxInterview for display percentage in java console by the best coders in the world

showing results for - "display percentage in java console"
María Paula
11 Nov 2019
1package org.kodejava.example.lang;
2
3public class ConsoleProgressBar {
4    public static void main(String[] args) {
5        char[] animationChars = new char[]{'|', '/', '-', '\\'};
6
7        for (int i = 0; i <= 100; i++) {
8            System.out.print("Processing: " + i + "% " + animationChars[i % 4] + "\r");
9
10            try {
11                Thread.sleep(100);
12            } catch (InterruptedException e) {
13                e.printStackTrace();
14            }
15        }
16
17        System.out.println("Processing: Done!          ");
18    }
19}
20
similar questions
queries leading to this page
display percentage in java console