Package org.dict.zip
Class RandomAccessInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.dict.zip.RandomAccessInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class RandomAccessInputStream extends InputStream
RandomAccessInputStream.
-
-
Constructor Summary
Constructors Constructor Description RandomAccessInputStream(RandomAccessFile inFile)
Construct RandomAccessInputStream from file.RandomAccessInputStream(String file, String mode)
Construct RandomAccessInputStream from filename.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
int
getLength()
Get file length.int
getPos()
Get cursor position.void
mark(int markpos)
boolean
markSupported()
int
read()
int
read(byte[] buf, int off, int len)
void
readFully(byte[] buf)
Read full data to byte buffer.void
reset()
void
seek(long pos)
Seek file position.long
skip(long size)
-
Methods inherited from class java.io.InputStream
nullInputStream, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
RandomAccessInputStream
public RandomAccessInputStream(RandomAccessFile inFile)
Construct RandomAccessInputStream from file.- Parameters:
inFile
- RandomAccessFile
-
RandomAccessInputStream
public RandomAccessInputStream(String file, String mode) throws IOException
Construct RandomAccessInputStream from filename.- Parameters:
file
- to read with random access.mode
- open mode.- Throws:
IOException
- if an I/O error has occurred.
-
-
Method Detail
-
available
public final int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public final void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
getLength
public final int getLength() throws IOException
Get file length.- Returns:
- length of file in byte.
- Throws:
IOException
- if an I/O error has occurred.
-
getPos
public final int getPos() throws IOException
Get cursor position.- Returns:
- position in byte.
- Throws:
IOException
- if an I/O error has occurred.
-
mark
public final void mark(int markpos)
- Overrides:
mark
in classInputStream
-
markSupported
public final boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
read
public final int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public final int read(byte[] buf, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
readFully
public final void readFully(byte[] buf) throws IOException
Read full data to byte buffer.- Parameters:
buf
- buffer to store data.- Throws:
IOException
- if an I/O error has occurred.
-
reset
public final void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
seek
public final void seek(long pos) throws IOException
Seek file position.- Parameters:
pos
- file position in byte.- Throws:
IOException
- if an I/O error has occurred.
-
skip
public final long skip(long size) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
-