Answers for "display percentage in java console"

0

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!          ");
    }
}
Posted by: Guest on August-12-2021

Code answers related to "display percentage in java console"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language