Class Pacer


  • public class Pacer
    extends Object
    A class used in command line utilities. This has little thingies pacing back and forth in front of the user -- it's an ASCII status bar.

    Usual use

    For a long-running task, rather than have the user stare at the screen and having them wonder if the app has hung, start a thread with the task, register this as a listener, then start this. It will pace back and forth until it gets notified the task is done.

    Invoke the main method of this to see a demo. Note that the pacing should happen on one line. There are some monitors where this does not do that due to how Java is implemented.

    Created by Jeff Gaynor
    on 3/26/20 at 10:36 AM

    • Constructor Detail

      • Pacer

        public Pacer​(int n)
        This sets how wide the pacer will be ( = 2*n). Be sure to leave space for any comments. A good value is 20.
      • Pacer

        public Pacer​(String message)
    • Method Detail

      • clear

        public void clear()
        Clears the current line of text. Call this when you want to clear where pacer was.
      • pace

        public void pace()
        Causes the pacer to pace once.
      • pace

        public void pace​(long items,
                         String tail)
        This will pace, and put a number + message after the pace line. Typical might be pace(counter++, "records read") Which might put out

        .../.....................\... 1234 records read

        Parameters:
        items - long
        tail - java.lang.String
      • pace

        public void pace​(long items)