Class Tailer

java.lang.Object
VASSAL.tools.io.Tailer

public class Tailer extends Object
Tail a file. This class is designed to behave similarly to the UNIX command tail -f, watching the file for changes and reporting them to listeners. The tailer may be stopped when it is not needed; if it is restarted, it will remember its last position and resume reading where it left off.
Since:
3.2.0
Author:
Joel Uckelman
  • Field Details

    • DEFAULT_POLL_INTERVAL

      protected static final long DEFAULT_POLL_INTERVAL
      See Also:
    • file

      protected final File file
    • poll_interval

      protected final long poll_interval
    • position

      protected long position
    • tailing

      protected volatile boolean tailing
    • lsup

      protected final EventListenerSupport<String> lsup
  • Constructor Details

    • Tailer

      public Tailer(File file)
      Creates a file tailer with the default polling interval.
      Parameters:
      file - the file to tail
    • Tailer

      public Tailer(File file, long poll_interval)
      Creates a file tailer.
      Parameters:
      file - the file to tail
      poll_interval - the polling interval, in milliseconds
    • Tailer

      public Tailer(File file, long poll_interval, EventListenerSupport<String> lsup)
      Creates a file tailer.
      Parameters:
      file - the file to tail
      poll_interval - the polling interval, in milliseconds
      lsup - the listener support
  • Method Details

    • start

      public void start() throws IOException
      Starts tailing the file.
      Throws:
      IOException
    • stop

      public void stop()
      Stops tailing the file.
    • isTailing

      public boolean isTailing()
      Checks whether the tailer is running.
      Returns:
      true if the tailer is running
    • getFile

      public File getFile()
      Gets the file being tailed.
      Returns:
      the file
    • addEventListener

      public void addEventListener(EventListener<? super String> l)
      Adds an EventListener.
      Parameters:
      l - the listener to add
    • removeEventListener

      public void removeEventListener(EventListener<? super String> l)
      Removes an EventListener.
      Parameters:
      l - the listener to remove
    • hasEventListeners

      public boolean hasEventListeners()
      Checks whether there are any EventListeners.
      Returns:
      true if there are any listeners
    • getEventListeners

      public List<EventListener<? super String>> getEventListeners()
      Gets the list of listerners.
      Returns:
      the list of listeners
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException