@InterfaceAudience.Private @InterfaceStability.Evolving public class ResettableFileInputStream extends ResettableInputStream implements RemoteMarkable, LengthMeasurable
reset() is dependent on the underlying PositionTracker instance's durability semantics.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUF_SIZE |
| Constructor and Description |
|---|
ResettableFileInputStream(File file,
PositionTracker tracker) |
ResettableFileInputStream(File file,
PositionTracker tracker,
int bufSize,
Charset charset,
DecodeErrorPolicy decodeErrorPolicy) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
long |
getMarkPosition()
Return the saved mark position without moving the mark pointer.
|
long |
length()
returns the total length of the stream or file
|
void |
mark()
Marks the current position in this input stream.
|
void |
markPosition(long position)
Indicate that the specified position should be returned to in the case of
Resettable.reset() being called. |
int |
read()
Read a single byte of data from the stream.
|
int |
read(byte[] b,
int off,
int len)
Read multiple bytes of data from the stream.
|
int |
readChar()
Read a single character.
|
void |
reset()
Reset stream position to that set by
ResettableInputStream.mark() |
void |
seek(long newPos)
Seek to the specified byte position in the stream.
|
long |
tell()
Tell the current byte position.
|
public static final int DEFAULT_BUF_SIZE
public ResettableFileInputStream(File file, PositionTracker tracker) throws IOException
file - File to readtracker - PositionTracker implementation to make offset position durableFileNotFoundExceptionIOExceptionpublic ResettableFileInputStream(File file, PositionTracker tracker, int bufSize, Charset charset, DecodeErrorPolicy decodeErrorPolicy) throws IOException
file - File to readtracker - PositionTracker implementation to make offset position durablebufSize - Size of the underlying buffer used for inputcharset - Character set used for decoding text, as necessaryFileNotFoundExceptionIOExceptionpublic int read()
throws IOException
ResettableInputStreamread in class ResettableInputStream-1 if the end of the stream has
been reached.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
ResettableInputStreamread in class ResettableInputStreamb - the buffer into which the data is read.off - Offset into the array b at which the data is written.len - the maximum number of bytes to read.-1 if
the end of the stream has been reached.IOExceptionpublic int readChar()
throws IOException
ResettableInputStreamRead a single character.
Note that this may lead to returning only one character in a 2-char surrogate pair sequence. When this happens, the underlying implementation should never persist a mark between two chars of a two-char surrogate pair sequence.
readChar in class ResettableInputStreamIOExceptionpublic void mark()
throws IOException
ResettableInputStreamreset method repositions this stream at the last marked
position so that subsequent reads re-read the same bytes.
Marking a closed stream should not have any effect on the stream.
mark in interface Resettablemark in class ResettableInputStreamIOException - If there is an error while setting the mark position.InputStream.mark(int),
InputStream.reset()public void markPosition(long position)
throws IOException
RemoteMarkableResettable.reset() being called.markPosition in interface RemoteMarkableIOExceptionpublic long getMarkPosition()
throws IOException
RemoteMarkablegetMarkPosition in interface RemoteMarkableIOExceptionpublic void reset()
throws IOException
ResettableInputStreamResettableInputStream.mark()reset in interface Resettablereset in class ResettableInputStreamIOExceptionpublic long length()
throws IOException
LengthMeasurablelength in interface LengthMeasurableIOExceptionpublic long tell()
throws IOException
ResettableInputStreamtell in interface Seekabletell in class ResettableInputStreamIOExceptionpublic void seek(long newPos)
throws IOException
ResettableInputStreamseek in interface Seekableseek in class ResettableInputStreamnewPos - Absolute byte offset to seek toIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class ResettableInputStreamIOExceptionCopyright © 2009-2014 Apache Software Foundation. All Rights Reserved.