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


Java Inflater.finished方法代码示例

本文整理汇总了Java中java.util.zip.Inflater.finished方法的典型用法代码示例。如果您正苦于以下问题:Java Inflater.finished方法的具体用法?Java Inflater.finished怎么用?Java Inflater.finished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.Inflater的用法示例。


在下文中一共展示了Inflater.finished方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getZipString

import java.util.zip.Inflater; //导入方法依赖的package包/类
public String getZipString() {
	int length = getBInt() - 4;
	int zlength = getLInt();

	if (remaining() > length) {
		Inflater decompressor = new Inflater();
		decompressor.setInput(buffer, offset, length);
		offset += length;

		try {
			ByteArrayOutputStream bos = new ByteArrayOutputStream(zlength);
			byte[] buf = new byte[1024];
			int count;
			while ((!decompressor.finished()) && ((count = decompressor.inflate(buf)) > 0)) {
				bos.write(buf, 0, count);
			}
			decompressor.end();
			bos.close();

			return new String(bos.toByteArray(), UTF8_CHARSET);
		} catch (DataFormatException | IOException ignored) {
		}
	}

	return null;
}
 
开发者ID:Tarik02,项目名称:cr-private-server,代码行数:27,代码来源:DataStream.java

示例2: decompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] decompress(byte[] value) throws DataFormatException
{

    ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);

    Inflater decompressor = new Inflater();

    try
    {
        decompressor.setInput(value);

        final byte[] buf = new byte[1024];
        while (!decompressor.finished())
        {
            int count = decompressor.inflate(buf);
            bos.write(buf, 0, count);
        }
    } finally
    {
        decompressor.end();
    }

    return bos.toByteArray();
}
 
开发者ID:WeDevelopTeam,项目名称:HeroVideo-master,代码行数:25,代码来源:BiliDanmukuCompressionTools.java

示例3: inflater

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * 解压缩.
 * 
 * @param inputByte
 *            byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
	int compressedDataLength = 0;
	Inflater compresser = new Inflater(false);
	compresser.setInput(inputByte, 0, inputByte.length);
	ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
	byte[] result = new byte[1024];
	try {
		while (!compresser.finished()) {
			compressedDataLength = compresser.inflate(result);
			if (compressedDataLength == 0) {
				break;
			}
			o.write(result, 0, compressedDataLength);
		}
	} catch (Exception ex) {
		System.err.println("Data format error!\n");
		ex.printStackTrace();
	} finally {
		o.close();
	}
	compresser.end();
	return o.toByteArray();
}
 
开发者ID:Javen205,项目名称:IJPay,代码行数:32,代码来源:SDKUtil.java

示例4: decompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
static byte[] decompress(byte[] bytesIn, int offset) throws Exception {
    Inflater inflater = new Inflater();
    inflater.setInput(bytesIn, offset, bytesIn.length - offset);
    ByteArrayOutputStream stream = new ByteArrayOutputStream(bytesIn.length - offset);
    byte[] buffer = new byte[1024];

    while (!inflater.finished()) {
        int count = inflater.inflate(buffer);
        stream.write(buffer, 0, count);
    }

    stream.close();

    byte[] bytesOut = stream.toByteArray();
    inflater.end();

    return bytesOut;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ZipDecompressor.java

示例5: inflater

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * 解压缩.
 *
 * @param inputByte byte[]数组类型的数据
 * @return 解压缩后的数据
 * @throws IOException
 */
public static byte[] inflater(final byte[] inputByte) throws IOException {
    int compressedDataLength = 0;
    Inflater compresser = new Inflater(false);
    compresser.setInput(inputByte, 0, inputByte.length);
    ByteArrayOutputStream o = new ByteArrayOutputStream(inputByte.length);
    byte[] result = new byte[1024];
    try {
        while (!compresser.finished()) {
            compressedDataLength = compresser.inflate(result);
            if (compressedDataLength == 0) {
                break;
            }
            o.write(result, 0, compressedDataLength);
        }
    } catch (Exception ex) {
        System.err.println("Data format error!\n");
        ex.printStackTrace();
    } finally {
        o.close();
    }
    compresser.end();
    return o.toByteArray();
}
 
开发者ID:howe,项目名称:nutz-pay,代码行数:31,代码来源:SDKUtil.java

示例6: deflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/** Descomprime un certificado contenido en la tarjeta CERES.
 * @param compressedCertificate Certificado comprimido en ZIP a partir del 9 octeto.
 * @return Certificado codificado.
 * @throws IOException Cuando se produce un error en la descompresión del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    final Inflater decompressor = new Inflater();
    decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
    final byte[] buf = new byte[1024];
    try {
        // Descomprimimos los datos
        while (!decompressor.finished()) {
            final int count = decompressor.inflate(buf);
            if (count == 0) {
                throw new DataFormatException();
            }
            buffer.write(buf, 0, count);
        }
        // Obtenemos los datos descomprimidos
        return buffer.toByteArray();
    }
    catch (final DataFormatException ex) {
        throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
    }
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:26,代码来源:Ceres.java

示例7: inflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * Inflate the given byte array by {@link #INFLATED_ARRAY_LENGTH}.
 *
 * @param bytes the bytes
 * @return the array as a string with {@code UTF-8} encoding
 */
public static String inflate(final byte[] bytes) {
    final Inflater inflater = new Inflater(true);
    final byte[] xmlMessageBytes = new byte[INFLATED_ARRAY_LENGTH];

    final byte[] extendedBytes = new byte[bytes.length + 1];
    System.arraycopy(bytes, 0, extendedBytes, 0, bytes.length);
    extendedBytes[bytes.length] = 0;

    inflater.setInput(extendedBytes);

    try {
        final int resultLength = inflater.inflate(xmlMessageBytes);
        inflater.end();

        if (!inflater.finished()) {
            throw new RuntimeException("buffer not large enough.");
        }

        inflater.end();
        return new String(xmlMessageBytes, 0, resultLength, StandardCharsets.UTF_8);
    } catch (final DataFormatException e) {
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:31,代码来源:CompressionUtils.java

示例8: readChunkUnzip

import java.util.zip.Inflater; //导入方法依赖的package包/类
private void readChunkUnzip(Inflater inflater, byte[] buffer, int offset, int length) throws IOException {
    try {
        do {
            int read = inflater.inflate(buffer, offset, length);
            if(read <= 0) {
                if(inflater.finished()) {
                    throw new EOFException();
                }
                if(inflater.needsInput()) {
                    refillInflater(inflater);
                } else {
                    throw new IOException("Can't inflate " + length + " bytes");
                }
            } else {
                offset += read;
                length -= read;
            }
        } while(length > 0);
    } catch (DataFormatException ex) {
        throw (IOException)(new IOException("inflate error").initCause(ex));
    }
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-C,代码行数:23,代码来源:PNGDecoder.java

示例9: onMessage

import java.util.zip.Inflater; //导入方法依赖的package包/类
@Override
public void onMessage(ByteBuffer message) {
	try {

		//Thanks to ShadowLordAlpha for code and debugging.
		//Get the compressed message and inflate it
		StringBuilder builder = new StringBuilder();
		Inflater decompresser = new Inflater();
		byte[] bytes = message.array();
		decompresser.setInput(bytes, 0, bytes.length);
		byte[] result = new byte[128];
		while (!decompresser.finished()) {
			int resultLength = decompresser.inflate(result);
			builder.append(new String(result, 0, resultLength, "UTF-8"));
		}
		decompresser.end();

		// send the inflated message to the TextMessage method
		onMessage(builder.toString());
	} catch (DataFormatException | UnsupportedEncodingException e) {
		e.printStackTrace();
	}
}
 
开发者ID:discord-java,项目名称:discord.jar,代码行数:24,代码来源:WebSocketClient.java

示例10: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] uncompress(byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:21,代码来源:LogUtils.java

示例11: decodeURLBase64DeflateString

import java.util.zip.Inflater; //导入方法依赖的package包/类
private String decodeURLBase64DeflateString(final String input)
        throws UnsupportedEncodingException, DataFormatException {
    String urlDecoded = URLDecoder.decode(input, "UTF-8");
    byte[] base64Decoded = Base64.decodeBase64(urlDecoded);

    Inflater decompresser = new Inflater(true);
    decompresser.setInput(base64Decoded);
    StringBuilder result = new StringBuilder();

    while (!decompresser.finished()) {
        byte[] outputFraction = new byte[base64Decoded.length];
        int resultLength = decompresser.inflate(outputFraction);
        result.append(new String(outputFraction, 0, resultLength, "UTF-8"));
    }

    return result.toString();
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:RedirectSamlURLBuilderTest.java

示例12: deflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
/** Descomprime un certificado contenido en el DNIe.
 * @param compressedCertificate Certificado comprimido en ZIP a partir del 9 byte.
 * @return Certificado codificado.
 * @throws IOException Cuando se produce un error en la descompresion del certificado. */
private static byte[] deflate(final byte[] compressedCertificate) throws IOException {
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    final Inflater decompressor = new Inflater();
    decompressor.setInput(compressedCertificate, 8, compressedCertificate.length - 8);
    final byte[] buf = new byte[1024];
    try {
        // Descomprimimos los datos
        while (!decompressor.finished()) {
            final int count = decompressor.inflate(buf);
            if (count == 0) {
                throw new DataFormatException();
            }
            buffer.write(buf, 0, count);
        }
        // Obtenemos los datos descomprimidos
        return buffer.toByteArray();
    }
    catch (final DataFormatException ex) {
        throw new IOException("Error al descomprimir el certificado: " + ex, ex); //$NON-NLS-1$
    }
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:26,代码来源:Dnie.java

示例13: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
@Override
public byte[] uncompress(byte[] data) throws IOException {
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	Inflater decompressor = new Inflater();
	
	try {
		decompressor.setInput(data);
		final byte[] buf = new byte[2048];
		while (!decompressor.finished()) {
			int count = decompressor.inflate(buf);
			bos.write(buf, 0, count);
		}
	} catch (DataFormatException e) {
		e.printStackTrace();
	} finally {
		decompressor.end();
	}
	
	return bos.toByteArray();
}
 
开发者ID:yu120,项目名称:compress,代码行数:21,代码来源:DeflaterCompress.java

示例14: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static byte[] uncompress(final byte[] input) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    Inflater decompressor = new Inflater();
    try {
        decompressor.setInput(input);
        final byte[] buf = new byte[2048];
        while (!decompressor.finished()) {
            int count = 0;
            try {
                count = decompressor.inflate(buf);
            } catch (DataFormatException e) {
                e.printStackTrace();
            }
            bos.write(buf, 0, count);
        }
    } finally {
        decompressor.end();
    }
    return bos.toByteArray();
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:21,代码来源:LogUtils.java

示例15: getData

import java.util.zip.Inflater; //导入方法依赖的package包/类
public ByteBuffer getData() {
    try {
        byte[] input = new byte[1024];
        byte[] output = new byte[1024];
        FileInputStream fin = new FileInputStream(file);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Inflater inflater = new Inflater(true);

        while (true) {
            int numRead = fin.read(input);
            if (numRead != -1) {
                inflater.setInput(input, 0, numRead);
            }

            int numDecompressed;
            while ((numDecompressed = inflater.inflate(output, 0, output.length)) != 0) {
                bos.write(output, 0, numDecompressed);
            }

            if (inflater.finished()) {
                break;
            }
            else if (inflater.needsInput()) {
                continue;
            }
        }

        inflater.end();
        ByteBuffer result = ByteBuffer.wrap(bos.toByteArray(), 0, bos.size());

        bos.close();
        fin.close();

        return result;
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }

    return null;
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:41,代码来源:Slice.java


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