Package com.aoindustries.io
Class LogFollower
- java.lang.Object
-
- java.io.InputStream
-
- com.aoindustries.io.LogFollower
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class LogFollower extends InputStream
Reads data as is it appended to a log file. If the log file is closed and recreated, which is typical during log rotations, the new file is opened and read from the beginning. The file is assumed to have been replaced when its length is smaller than before.This class will block on read. If end of file is reached, it will continue to block until data becomes available. End of file is never returned from this class, it will wait indefinitely for data.
- Author:
- AO Industries, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_POLL_INTERVAL
-
Constructor Summary
Constructors Constructor Description LogFollower(File file)LogFollower(File file, int pollInterval)LogFollower(String path)LogFollower(String path, int pollInterval)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intavailable()voidclose()protected voidfinalize()Deprecated.The finalization mechanism is inherently problematic.intgetPollInterval()intread()intread(byte[] b, int offset, int len)longskip(long n)-
Methods inherited from class java.io.InputStream
mark, markSupported, read, reset
-
-
-
-
Field Detail
-
DEFAULT_POLL_INTERVAL
public static final int DEFAULT_POLL_INTERVAL
- See Also:
- Constant Field Values
-
-
Method Detail
-
available
public int available() throws IOException- Overrides:
availablein classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
getPollInterval
public int getPollInterval()
-
finalize
@Deprecated protected void finalize() throws Throwable
Deprecated.The finalization mechanism is inherently problematic.
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] b, int offset, int len) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classInputStream- Throws:
IOException
-
-