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 void
close()
Closes the input stream.int
getChunkCount()
Get number of chunks.int
getChunkLength()
Get length of each chunk.long
getCompLength()
Get total length of compressed data.long
getCrc()
Return CRC value set to gzip trailer.String
getFilename()
Get Filename field if exist.long
getLength()
Return length value set to gzip trailer.long
getMtime()
Get mtime in long.String
getType()
Get type of compression.int
read(byte[] buffer, int off, int size)
Reads uncompressed data into an array of bytes.void
readFully(byte[] buffer)
Read full data.void
readFully(byte[] buffer, int off, int size)
Read full data by offset/length.void
seek(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 IOException
Closes the input stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInflaterInputStream
- Throws:
IOException
- if an I/O error has occurred
-
read
public final int read(byte[] buffer, int off, int size) throws IOException
Reads uncompressed data into an array of bytes. Blocks until enough input is available for decompression.- Overrides:
read
in 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 IOException
Read 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 IOException
Read 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 IOException
Seek to a raw index next.- Parameters:
next
- a raw index- Throws:
IOException
- when instance is not a RandomAccessInputStream.
-
getCrc
public long getCrc() throws IOException
Return CRC value set to gzip trailer.- Returns:
- CRC value.
- Throws:
IOException
- if I/O error.
-
getLength
public long getLength() throws IOException
Return length value set to gzip trailer.- Returns:
- data length.
- Throws:
IOException
- if I/O error.
-
getCompLength
public long getCompLength() throws IOException
Get 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 IOException
Get length of each chunk.- Returns:
- size of chunk.
- Throws:
IOException
- if I/O error occurred.
-
getChunkCount
public int getChunkCount() throws IOException
Get number of chunks.- Returns:
- number of chunks.
- Throws:
IOException
- if I/O error occurred.
-
getMtime
public long getMtime() throws IOException
Get 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.
-
-