Is this the best way to print dynamic percent value?
Standing on the shoulders of @rolfl…

I would prefer to use a carriage return to return the cursor to the beginning of the line, as it's a bit less fragile than backspacing.

public static void main(String[] args) {
    // Java's Printwriter.format() doesn't tell you how many characters
    // it produced; 30 characters is an overestimate to ensure that
    // the entire "Percent completed: ***%" string gets overwritten.
    final String CLEARLINE_FMT = "\r%30s\r";

    try {
        for (int i = 0; i &lt; 100; i++) {
            System.out.printf("\rPercent completed: %3d%%", i);
            Thread.sleep(500);
        }
        System.out.printf(CLEARLINE_FMT + "Done!\n", "");
    } catch (InterruptedException e) {
        System.out.printf(CLEARLINE_FMT + "Interrupted!\n", "");
    }
}


Or, if you want to print "100%" instead of "Done!":

public static void main(String[] args) {
    // Java's Printwriter.format() doesn't tell you how many characters
    // it produced; 30 characters is an overestimate to ensure that
    // the entire "Percent completed: ***%" string gets overwritten.
    final String CLEARLINE_FMT = "\r%30s\r";

    try {
        for (int i = 0; ; i++) {
            System.out.printf("\rPercent completed: %3d%%", i);
            if (i &gt;= 100) {
                System.out.println();
                break;
            }
            Thread.sleep(500);
        }
    } catch (InterruptedException e) {
        System.out.printf(CLEARLINE_FMT + "Interrupted!\n", "");
    }
}