Package VASSAL.tools.io
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
Modifier and TypeFieldDescriptionprotected static final long
protected final File
protected final EventListenerSupport
<String> protected final long
protected long
protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(EventListener<? super String> l) Adds anEventListener
.List
<EventListener<? super String>> Gets the list of listerners.getFile()
Gets the file being tailed.boolean
Checks whether there are anyEventListener
s.boolean
Checks whether the tailer is running.static void
void
removeEventListener
(EventListener<? super String> l) Removes anEventListener
.void
start()
Starts tailing the file.void
stop()
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:
true
if 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 anyEventListener
s.- Returns:
true
if there are any listeners
-
getEventListeners
Gets the list of listerners.- Returns:
- the list of listeners
-
main
- Throws:
IOException
-