本文整理汇总了Java中com.jcraft.jzlib.InflaterInputStream类的典型用法代码示例。如果您正苦于以下问题:Java InflaterInputStream类的具体用法?Java InflaterInputStream怎么用?Java InflaterInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InflaterInputStream类属于com.jcraft.jzlib包,在下文中一共展示了InflaterInputStream类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.jcraft.jzlib.InflaterInputStream; //导入依赖的package包/类
public LiteralTableChunk read() throws Throwable {
LiteralTableChunk literalTableChunk = new LiteralTableChunk(chunk());
int uncompressedSize = read4Bytes();
byte[] uncompressed = new byte[uncompressedSize];
int offset = 0;
int left = uncompressedSize;
try (InflaterInputStream iis = new InflaterInputStream(inputStream())) {
do {
int decompressed = iis.read(uncompressed, offset, left);
offset += decompressed;
left -= decompressed;
} while (left > 0);
}
setInputStream(new DataInputStream(new ByteArrayInputStream(uncompressed)));
int literals = read4Bytes();
while (literals-- > 0) {
read4Bytes(); // length of literal
literalTableChunk.add(readTerm());
}
return literalTableChunk;
}
示例2: uncompress
import com.jcraft.jzlib.InflaterInputStream; //导入依赖的package包/类
/**
* Uncompress.
*
* @param compressedData
* the compressed data
* @param uncompressedLength
* the uncompressed length
* @return the byte[]
*/
protected byte[] uncompress(final byte[] compressedData, final long uncompressedLength) {
final byte[] uncompressedData = new byte[(int) uncompressedLength];
try {
final ByteArrayInputStream input = new ByteArrayInputStream(compressedData);
final InflaterInputStream decompressor = new InflaterInputStream(input);
decompressor.read(uncompressedData);
decompressor.close();
} catch (final IOException e) {
throw new IllegalArgumentException(e);
}
return uncompressedData;
}
示例3: getInputStream
import com.jcraft.jzlib.InflaterInputStream; //导入依赖的package包/类
@Override
public InputStream getInputStream(InputStream inputStream) throws IOException {
final InflaterInputStream is = new InflaterInputStream(inputStream);
return is;
}