public class SharedFileInputStream extends java.io.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 java.io.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(java.io.File file)
Construct a SharedFileInputStream from a File object, using the default buffer size.
|
SharedFileInputStream(java.io.File file,
int bufferSize)
Construct a SharedFileInputStream from a File object, with a given initial buffer size.
|
SharedFileInputStream(java.lang.String file)
Construct a SharedFileInputStream from a file name, using the default buffer size.
|
SharedFileInputStream(java.lang.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.
|
java.io.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.
|
protected long bufpos
protected int bufsize
protected long datalen
protected java.io.RandomAccessFile in
protected long start
public SharedFileInputStream(java.lang.String file)
throws java.io.IOException
file - The name of the file.java.io.IOExceptionpublic SharedFileInputStream(java.io.File file)
throws java.io.IOException
file - The name of the file.java.io.IOExceptionpublic SharedFileInputStream(java.lang.String file,
int bufferSize)
throws java.io.IOException
file - The name of the file.bufferSize - The initial buffer size.java.io.IOExceptionpublic SharedFileInputStream(java.io.File file,
int bufferSize)
throws java.io.IOException
file - The name of the file.bufferSize - The initial buffer size.java.io.IOExceptionpublic int available()
throws java.io.IOException
available in class java.io.BufferedInputStreamjava.io.IOExceptionpublic long getPosition()
getPosition in interface SharedInputStreampublic void mark(int readlimit)
mark in class java.io.BufferedInputStreamreadlimit - The limit for the distance the read position can move from
the mark position before the mark is reset.public int read()
throws java.io.IOException
read in class java.io.BufferedInputStreamjava.io.IOExceptionpublic int read(byte[] buffer,
int offset,
int length)
throws java.io.IOException
read in class java.io.BufferedInputStreambuffer - The target buffer.offset - The offset within the buffer to place the data.length - The length to attempt to read.java.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.BufferedInputStreamn - The number of bytes to skip.java.io.IOExceptionpublic void reset()
throws java.io.IOException
reset in class java.io.BufferedInputStreamjava.io.IOExceptionpublic boolean markSupported()
markSupported in class java.io.BufferedInputStreampublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.BufferedInputStreamjava.io.IOExceptionpublic java.io.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.