當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。