Class Tailer
java.lang.Object
VASSAL.tools.io.Tailer
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final longprotected final Fileprotected final EventListenerSupport<String> protected final longprotected longprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(EventListener<? super String> l) Adds anEventListener.List<EventListener<? super String>> Gets the list of listerners.getFile()Gets the file being tailed.booleanChecks whether there are anyEventListeners.booleanChecks whether the tailer is running.static voidvoidremoveEventListener(EventListener<? super String> l) Removes anEventListener.voidstart()Starts tailing the file.voidstop()Stops tailing the file.
-
Field Details
-
DEFAULT_POLL_INTERVAL
protected static final long DEFAULT_POLL_INTERVAL- See Also:
-
file
-
poll_interval
protected final long poll_interval -
position
protected long position -
tailing
protected volatile boolean tailing -
lsup
-
-
Constructor Details
-
Tailer
Creates a file tailer with the default polling interval.- Parameters:
file- the file to tail
-
Tailer
Creates a file tailer.- Parameters:
file- the file to tailpoll_interval- the polling interval, in milliseconds
-
Tailer
Creates a file tailer.- Parameters:
file- the file to tailpoll_interval- the polling interval, in millisecondslsup- the listener support
-
-
Method Details
-
start
-
stop
public void stop()Stops tailing the file. -
isTailing
public boolean isTailing()Checks whether the tailer is running.- Returns:
trueif the tailer is running
-
getFile
-
addEventListener
Adds anEventListener.- Parameters:
l- the listener to add
-
removeEventListener
Removes anEventListener.- Parameters:
l- the listener to remove
-
hasEventListeners
public boolean hasEventListeners()Checks whether there are anyEventListeners.- Returns:
trueif there are any listeners
-
getEventListeners
Gets the list of listerners.- Returns:
- the list of listeners
-
main
- Throws:
IOException
-