Package com.attivio.util
Class Tailer
- java.lang.Object
-
- com.attivio.util.Tailer
-
- All Implemented Interfaces:
java.lang.Runnable
public class Tailer extends java.lang.Object implements java.lang.Runnable
Version ofTailer
that lets you set the start position
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Tailer.TailerListener
-
Constructor Summary
Constructors Constructor Description Tailer(java.io.File file, Tailer.TailerListener listener)
Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.Tailer(java.io.File file, Tailer.TailerListener listener, long delay)
Creates a Tailer for the given file, starting from the beginning.Tailer(java.io.File file, Tailer.TailerListener listener, long delay, long position)
Creates a Tailer for the given file, with a delay other than the default 1.0s.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Tailer
create(java.io.File file, Tailer.TailerListener listener)
Creates and starts a Tailer for the given file, starting at the beginning of the file with the default delay of 1.0sstatic Tailer
create(java.io.File file, Tailer.TailerListener listener, long delay)
Creates and starts a Tailer for the given file, starting at the beginning of the filestatic Tailer
create(java.io.File file, Tailer.TailerListener listener, long delay, long startingPosition)
Creates and starts a Tailer for the given file.long
getDelay()
Return the delay.java.io.File
getFile()
Return the file.void
run()
Follows changes in the file, calling the TailerListener's handle method for each new line.void
stop()
Allows the tailer to complete its current loop and return.
-
-
-
Constructor Detail
-
Tailer
public Tailer(java.io.File file, Tailer.TailerListener listener)
Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.- Parameters:
file
- The file to follow.listener
- the TailerListener to use.
-
Tailer
public Tailer(java.io.File file, Tailer.TailerListener listener, long delay)
Creates a Tailer for the given file, starting from the beginning.- Parameters:
file
- the file to follow.listener
- the TailerListener to use.delay
- the delay between checks of the file for new content in milliseconds.
-
Tailer
public Tailer(java.io.File file, Tailer.TailerListener listener, long delay, long position)
Creates a Tailer for the given file, with a delay other than the default 1.0s.- Parameters:
file
- the file to follow.listener
- the TailerListener to use.delay
- the delay between checks of the file for new content in milliseconds.position
- Set to true to tail from the end of the file, false to tail from the beginning of the file.
-
-
Method Detail
-
create
public static Tailer create(java.io.File file, Tailer.TailerListener listener, long delay, long startingPosition)
Creates and starts a Tailer for the given file.- Parameters:
file
- the file to follow.listener
- the TailerListener to use.delay
- the delay between checks of the file for new content in milliseconds.startingPosition
- set to Long.MAX_VALUE to start at the end- Returns:
- The new tailer
-
create
public static Tailer create(java.io.File file, Tailer.TailerListener listener, long delay)
Creates and starts a Tailer for the given file, starting at the beginning of the file- Parameters:
file
- the file to follow.listener
- the TailerListener to use.delay
- the delay between checks of the file for new content in milliseconds.- Returns:
- The new tailer
-
create
public static Tailer create(java.io.File file, Tailer.TailerListener listener)
Creates and starts a Tailer for the given file, starting at the beginning of the file with the default delay of 1.0s- Parameters:
file
- the file to follow.listener
- the TailerListener to use.- Returns:
- The new tailer
-
getFile
public java.io.File getFile()
Return the file.- Returns:
- the file
-
getDelay
public long getDelay()
Return the delay.- Returns:
- the delay
-
run
public void run()
Follows changes in the file, calling the TailerListener's handle method for each new line.- Specified by:
run
in interfacejava.lang.Runnable
-
stop
public void stop()
Allows the tailer to complete its current loop and return.
-
-