Package org.dict.zip
Class DictZipInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.util.zip.InflaterInputStream
-
- org.dict.zip.DictZipInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DictZipInputStream extends InflaterInputStream
DictZipInputStream.
-
-
Field Summary
-
Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description DictZipInputStream(String filename)Creates a new input stream with a default buffer size from given filepath.DictZipInputStream(RandomAccessInputStream in)Creates a new input stream with a default buffer size.DictZipInputStream(RandomAccessInputStream in, int size)Creates a new input stream with the specified buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the input stream.intgetChunkCount()Get number of chunks.intgetChunkLength()Get length of each chunk.longgetCompLength()Get total length of compressed data.longgetCrc()Return CRC value set to gzip trailer.StringgetFilename()Get Filename field if exist.longgetLength()Return length value set to gzip trailer.longgetMtime()Get mtime in long.StringgetType()Get type of compression.intread(byte[] buffer, int off, int size)Reads uncompressed data into an array of bytes.voidreadFully(byte[] buffer)Read full data.voidreadFully(byte[] buffer, int off, int size)Read full data by offset/length.voidseek(long next)Seek to a raw index next.-
Methods inherited from class java.util.zip.InflaterInputStream
available, fill, mark, markSupported, read, reset, skip
-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
DictZipInputStream
public DictZipInputStream(String filename) throws IOException
Creates a new input stream with a default buffer size from given filepath.- Parameters:
filename- the input filename- Throws:
IOException- if an I/O error has occurred
-
DictZipInputStream
public DictZipInputStream(RandomAccessInputStream in) throws IOException
Creates a new input stream with a default buffer size.- Parameters:
in- the input stream- Throws:
IOException- if an I/O error has occurred
-
DictZipInputStream
public DictZipInputStream(RandomAccessInputStream in, int size) throws IOException
Creates a new input stream with the specified buffer size.- Parameters:
in- the input streamsize- the input buffer size- Throws:
IOException- if an I/O error has occurred
-
-
Method Detail
-
close
public final void close() throws IOExceptionCloses the input stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInflaterInputStream- Throws:
IOException- if an I/O error has occurred
-
read
public final int read(byte[] buffer, int off, int size) throws IOExceptionReads uncompressed data into an array of bytes. Blocks until enough input is available for decompression.- Overrides:
readin classInflaterInputStream- Parameters:
buffer- the buffer into which the data is readoff- the start offset of the datasize- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end of the compressed input stream is reached
- Throws:
IOException- if an I/O error has occurred or the compressed input data is corrupt
-
readFully
public final void readFully(byte[] buffer) throws IOExceptionRead full data.- Parameters:
buffer- the buffer into which the data is read- Throws:
IOException- if an I/O error has occurred or the compressed input data is corrupt
-
readFully
public final void readFully(byte[] buffer, int off, int size) throws IOExceptionRead full data by offset/length.- Parameters:
buffer- the buffer into which the data is readoff- offsetsize- length- Throws:
IOException- if an I/O error has occurred or the compressed input data is corrupt
-
seek
public void seek(long next) throws IOExceptionSeek to a raw index next.- Parameters:
next- a raw index- Throws:
IOException- when instance is not a RandomAccessInputStream.
-
getCrc
public long getCrc() throws IOExceptionReturn CRC value set to gzip trailer.- Returns:
- CRC value.
- Throws:
IOException- if I/O error.
-
getLength
public long getLength() throws IOExceptionReturn length value set to gzip trailer.- Returns:
- data length.
- Throws:
IOException- if I/O error.
-
getCompLength
public long getCompLength() throws IOExceptionGet total length of compressed data.- Returns:
- total length
- Throws:
IOException- when I/O error at trailer reading.
-
getType
public String getType() throws IOException
Get type of compression.- Returns:
- "DZIP" or "GZIP"
- Throws:
IOException- if I/O error occurred.
-
getChunkLength
public int getChunkLength() throws IOExceptionGet length of each chunk.- Returns:
- size of chunk.
- Throws:
IOException- if I/O error occurred.
-
getChunkCount
public int getChunkCount() throws IOExceptionGet number of chunks.- Returns:
- number of chunks.
- Throws:
IOException- if I/O error occurred.
-
getMtime
public long getMtime() throws IOExceptionGet mtime in long.- Returns:
- mtime in long.
- Throws:
IOException- if I/O error occurred.
-
getFilename
public String getFilename() throws IOException
Get Filename field if exist.- Returns:
- filename or null.
- Throws:
IOException- if I/O error occurred.
-
-