Package com.github.junrar.io
Class SeekableReadOnlyInputStream
- java.lang.Object
-
- com.github.junrar.io.SeekableReadOnlyInputStream
-
- All Implemented Interfaces:
SeekableReadOnlyByteChannel
public class SeekableReadOnlyInputStream extends java.lang.Object implements SeekableReadOnlyByteChannel
InputStream based implementation of theSeekableReadOnlyByteChannelinterface.http://rsbweb.nih.gov/ij/
-
-
Field Summary
Fields Modifier and Type Field Description private RandomAccessInputStreamis
-
Constructor Summary
Constructors Constructor Description SeekableReadOnlyInputStream(java.io.InputStream is)Create new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this channel.longgetPosition()intread()Read a single byte of data.intread(byte[] buffer, int off, int count)Read up tocountbytes to the specified buffer.intreadFully(byte[] buffer, int count)Read exactlycountbytes to the specified buffer.voidsetPosition(long pos)
-
-
-
Field Detail
-
is
private final RandomAccessInputStream is
-
-
Method Detail
-
getPosition
public long getPosition() throws java.io.IOException- Specified by:
getPositionin interfaceSeekableReadOnlyByteChannel- Returns:
- the current position in the channel
- Throws:
java.io.IOException- .
-
setPosition
public void setPosition(long pos) throws java.io.IOException- Specified by:
setPositionin interfaceSeekableReadOnlyByteChannel- Parameters:
pos- the position in the channel- Throws:
java.io.IOException- .
-
read
public int read() throws java.io.IOExceptionDescription copied from interface:SeekableReadOnlyByteChannelRead a single byte of data.- Specified by:
readin interfaceSeekableReadOnlyByteChannel- Returns:
- read read
- Throws:
java.io.IOException- .
-
read
public int read(byte[] buffer, int off, int count) throws java.io.IOExceptionDescription copied from interface:SeekableReadOnlyByteChannelRead up tocountbytes to the specified buffer.- Specified by:
readin interfaceSeekableReadOnlyByteChannel- Parameters:
buffer- .off- .count- .- Returns:
- read read
- Throws:
java.io.IOException- .
-
readFully
public int readFully(byte[] buffer, int count) throws java.io.IOExceptionDescription copied from interface:SeekableReadOnlyByteChannelRead exactlycountbytes to the specified buffer.- Specified by:
readFullyin interfaceSeekableReadOnlyByteChannel- Parameters:
buffer- where to store the read datacount- how many bytes to read- Returns:
- bytes read || -1 if IO problem
- Throws:
java.io.IOException- .
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:SeekableReadOnlyByteChannelClose this channel.- Specified by:
closein interfaceSeekableReadOnlyByteChannel- Throws:
java.io.IOException- .
-
-