当前位置: 首页>>代码示例>>Java>>正文


Java JZlib.Z_STREAM_END属性代码示例

本文整理汇总了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);
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:26,代码来源:TDeflater.java

示例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;
	}
 
开发者ID:andreynovikov,项目名称:androzic-library,代码行数:19,代码来源:OzfDecoder.java

示例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);
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:42,代码来源:JZlibEncoder.java

示例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);
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:41,代码来源:TInflater.java


注:本文中的com.jcraft.jzlib.JZlib.Z_STREAM_END属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。