Package org.apache.commons.io.input
Interface Tailer.RandomAccessResourceBridge
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- Enclosing class:
- Tailer
public static interface Tailer.RandomAccessResourceBridge extends java.io.Closeable
Bridges access to a resource for random access, normally a file. Allows substitution of remote files for example using jCIFS.- Since:
- 2.12.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getPointer()
Gets the current offset in this tailable.int
read(byte[] b)
Reads up tob.length
bytes of data from this tailable into an array of bytes.void
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this tailable, at which the next read or write occurs.
-
-
-
Method Detail
-
getPointer
long getPointer() throws java.io.IOException
Gets the current offset in this tailable.- 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
int read(byte[] b) throws java.io.IOException
Reads up tob.length
bytes of data from this tailable into an array of bytes. This method blocks until at least one byte of input is available.- Parameters:
b
- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or
-1
if 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
void seek(long pos) throws java.io.IOException
Sets 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.- Parameters:
pos
- the offset position, measured in bytes from the beginning of the tailable, at which to set the tailable pointer.- Throws:
java.io.IOException
- ifpos
is less than0
or if an I/O error occurs.
-
-