本文整理汇总了Java中com.jcraft.jzlib.JZlib.Z_STREAM_END属性的典型用法代码示例。如果您正苦于以下问题:Java JZlib.Z_STREAM_END属性的具体用法?Java JZlib.Z_STREAM_END怎么用?Java JZlib.Z_STREAM_END使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.jcraft.jzlib.JZlib
的用法示例。
在下文中一共展示了JZlib.Z_STREAM_END属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deflate
int deflate(byte[] buf, int off, int nbytes, int flushParam) {
if (impl == null) {
throw new IllegalStateException();
}
// avoid int overflow, check null buf
if (off > buf.length || nbytes < 0 || off < 0 || buf.length - off < nbytes) {
throw new ArrayIndexOutOfBoundsException();
}
long sin = impl.total_in;
long sout = impl.total_out;
impl.setOutput(buf, off, nbytes);
int err = impl.deflate(flushParam);
switch (err) {
case JZlib.Z_OK:
break;
case JZlib.Z_STREAM_END:
finished = true;
break;
default:
throw new RuntimeException("Error: " + err);
}
inRead += impl.total_in - sin;
return (int) (impl.total_out - sout);
}
示例2: decompressTile
private static boolean decompressTile(byte[] dest, byte[] source)
{
zip.next_in = source;
zip.avail_in = source.length;
zip.next_in_index = 0;
zip.next_out = dest;
zip.avail_out = dest.length;
zip.next_out_index=0;
zip.inflateInit();
int err = zip.inflate(JZlib.Z_FINISH);
if (err != JZlib.Z_OK && err != JZlib.Z_STREAM_END)
{
return false;
}
// decompressed_size = (int) zip.total_out;
zip.inflateEnd();
return true;
}
示例3: finishEncode
private ChannelFuture finishEncode(ChannelHandlerContext ctx, ChannelPromise promise) {
if (finished) {
promise.setSuccess();
return promise;
}
finished = true;
ByteBuf footer;
try {
// Configure input.
z.next_in = EmptyArrays.EMPTY_BYTES;
z.next_in_index = 0;
z.avail_in = 0;
// Configure output.
byte[] out = new byte[32]; // room for ADLER32 + ZLIB / CRC32 + GZIP header
z.next_out = out;
z.next_out_index = 0;
z.avail_out = out.length;
// Write the ADLER32 checksum (stream footer).
int resultCode = z.deflate(JZlib.Z_FINISH);
if (resultCode != JZlib.Z_OK && resultCode != JZlib.Z_STREAM_END) {
promise.setFailure(ZlibUtil.deflaterException(z, "compression failure", resultCode));
return promise;
} else if (z.next_out_index != 0) {
footer = Unpooled.wrappedBuffer(out, 0, z.next_out_index);
} else {
footer = Unpooled.EMPTY_BUFFER;
}
} finally {
z.deflateEnd();
// Deference the external references explicitly to tell the VM that
// the allocated byte arrays are temporary so that the call stack
// can be utilized.
// I'm not sure if the modern VMs do this optimization though.
z.next_in = null;
z.next_out = null;
}
return ctx.writeAndFlush(footer, promise);
}
示例4: inflate
public int inflate(byte[] buf, int off, int nbytes) throws TDataFormatException {
// avoid int overflow, check null buf
if (off > buf.length || nbytes < 0 || off < 0 || buf.length - off < nbytes) {
throw new ArrayIndexOutOfBoundsException();
}
if (impl == null) {
throw new IllegalStateException();
}
if (needsInput()) {
return 0;
}
long lastInSize = impl.total_in;
long lastOutSize = impl.total_out;
boolean neededDict = needsDictionary;
needsDictionary = false;
impl.setOutput(buf, off, nbytes);
int errCode = impl.inflate(0);
switch (errCode) {
case JZlib.Z_OK:
break;
case JZlib.Z_NEED_DICT:
needsDictionary = true;
break;
case JZlib.Z_STREAM_END:
finished = true;
break;
default:
throw new TDataFormatException("Error occurred: " + errCode);
}
if (needsDictionary && neededDict) {
throw new TDataFormatException();
}
inRead += impl.total_in - lastInSize;
return (int) (impl.total_out - lastOutSize);
}