Package org.apache.commons.io.input
Class Tailer.RandomAccessFileBridge
- java.lang.Object
-
- org.apache.commons.io.input.Tailer.RandomAccessFileBridge
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Tailer.RandomAccessResourceBridge
- Enclosing class:
- Tailer
private static final class Tailer.RandomAccessFileBridge extends java.lang.Object implements Tailer.RandomAccessResourceBridge
Bridges random access to aRandomAccessFile.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.RandomAccessFilerandomAccessFile
-
Constructor Summary
Constructors Modifier Constructor Description privateRandomAccessFileBridge(java.io.File file, java.lang.String mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()longgetPointer()Gets the current offset in this tailable.intread(byte[] b)Reads up tob.lengthbytes of data from this tailable into an array of bytes.voidseek(long position)Sets the file-pointer offset, measured from the beginning of this tailable, at which the next read or write occurs.
-
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getPointer
public long getPointer() throws java.io.IOExceptionDescription copied from interface:Tailer.RandomAccessResourceBridgeGets the current offset in this tailable.- Specified by:
getPointerin interfaceTailer.RandomAccessResourceBridge- Returns:
- the offset from the beginning of the tailable, in bytes, at which the next read or write occurs.
- Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(byte[] b) throws java.io.IOExceptionDescription copied from interface:Tailer.RandomAccessResourceBridgeReads up tob.lengthbytes of data from this tailable into an array of bytes. This method blocks until at least one byte of input is available.- Specified by:
readin interfaceTailer.RandomAccessResourceBridge- Parameters:
b- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of this tailable has been reached. - Throws:
java.io.IOException- If the first byte cannot be read for any reason other than end of tailable, or if the random access tailable has been closed, or if some other I/O error occurs.
-
seek
public void seek(long position) throws java.io.IOExceptionDescription copied from interface:Tailer.RandomAccessResourceBridgeSets the file-pointer offset, measured from the beginning of this tailable, at which the next read or write occurs. The offset may be set beyond the end of the tailable. Setting the offset beyond the end of the tailable does not change the tailable length. The tailable length will change only by writing after the offset has been set beyond the end of the tailable.- Specified by:
seekin interfaceTailer.RandomAccessResourceBridge- Parameters:
position- the offset position, measured in bytes from the beginning of the tailable, at which to set the tailable pointer.- Throws:
java.io.IOException- ifposis less than0or if an I/O error occurs.
-
-