public class SharedFileInputStream extends BufferedInputStream implements SharedInputStream
| Modifier and Type | Field and Description |
|---|---|
protected long |
bufpos
The file offset that is the first byte in the read buffer.
|
protected int |
bufsize
The normal size of the read buffer.
|
protected long |
datalen
The size of the file subset represented by this stream instance.
|
protected RandomAccessFile |
in
The source of the file data.
|
protected long |
start
The starting position of data represented by this stream relative
to the start of the file data.
|
| Constructor and Description |
|---|
SharedFileInputStream(File file)
Construct a SharedFileInputStream from a File object, using the default buffer size.
|
SharedFileInputStream(File file,
int bufferSize)
Construct a SharedFileInputStream from a File object, with a given initial buffer size.
|
SharedFileInputStream(String file)
Construct a SharedFileInputStream from a file name, using the default buffer size.
|
SharedFileInputStream(String file,
int bufferSize)
Construct a SharedFileInputStream from a file name, with a given initial buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Return the number of bytes available for reading without
blocking for a long period.
|
void |
close()
Close the stream.
|
long |
getPosition()
Return the current read position of the stream.
|
void |
mark(int readlimit)
Mark the current position for retracing.
|
boolean |
markSupported()
Indicates the mark() operation is supported.
|
InputStream |
newStream(long offset,
long end)
Create a new stream from this stream, using the given
start offset and length.
|
int |
read()
Read a single byte of data from the input stream.
|
int |
read(byte[] buffer,
int offset,
int length)
Read multiple bytes of data and place them directly into
a byte-array buffer.
|
void |
reset()
Reset the mark position.
|
long |
skip(long n)
Skip the read pointer ahead a given number of bytes.
|
readprotected long bufpos
protected int bufsize
protected long datalen
protected RandomAccessFile in
protected long start
public SharedFileInputStream(String file) throws IOException
file - The name of the file.IOExceptionpublic SharedFileInputStream(File file) throws IOException
file - The name of the file.IOExceptionpublic SharedFileInputStream(String file, int bufferSize) throws IOException
file - The name of the file.bufferSize - The initial buffer size.IOExceptionpublic SharedFileInputStream(File file, int bufferSize) throws IOException
file - The name of the file.bufferSize - The initial buffer size.IOExceptionpublic int available()
throws IOException
available in class BufferedInputStreamIOExceptionpublic long getPosition()
getPosition in interface SharedInputStreampublic void mark(int readlimit)
mark in class BufferedInputStreamreadlimit - The limit for the distance the read position can move from
the mark position before the mark is reset.public int read()
throws IOException
read in class BufferedInputStreamIOExceptionpublic int read(byte[] buffer,
int offset,
int length)
throws IOException
read in class BufferedInputStreambuffer - The target buffer.offset - The offset within the buffer to place the data.length - The length to attempt to read.IOExceptionpublic long skip(long n)
throws IOException
skip in class BufferedInputStreamn - The number of bytes to skip.IOExceptionpublic void reset()
throws IOException
reset in class BufferedInputStreamIOExceptionpublic boolean markSupported()
markSupported in class BufferedInputStreampublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class BufferedInputStreamIOExceptionpublic InputStream newStream(long offset, long end)
newStream in interface SharedInputStreamoffset - The offset relative to the start of this stream instance.end - The end offset of the substream. If -1, the end of the parent stream is used.Copyright © 2013. All Rights Reserved.