0

I wanted to show progress bar in console by replacing old character by new character so that only one character will be shown at any given time. Example:

        char[] progressBarChars = { '/', '-', '\\', '-' };
        for(int i=0; i<progressBarChars.length; i++) {
            System.err.print("\r"+progressBarChars[i]);//it is not replacing previous character in console. i don't want to see previous char in console
        }

Output: i should be able to see characters are getting replaced in a single line/place in console.

  • possible duplicate of: https://stackoverflow.com/questions/13146640/how-to-delete-previous-character-printed-to-console-terminal – sagarr Apr 26 '20 at 10:07
  • Does this answer your question? [How to delete previous character printed to console/terminal?](https://stackoverflow.com/questions/13146640/how-to-delete-previous-character-printed-to-console-terminal) – sagarr Apr 26 '20 at 10:07
  • No, i dont need new line – U_R_Naveen UR_Naveen Apr 26 '20 at 10:21
  • *"but no use"* What does that mean? I mean other than it doing it so fast that you cannot see the progression? That's why the suggested links has code with `Thread.sleep(1000)` to slow it down. – Andreas Apr 26 '20 at 10:33

0 Answers0