當前位置: 首頁>>代碼示例>>Java>>正文


Java Inflater.end方法代碼示例

本文整理匯總了Java中java.util.zip.Inflater.end方法的典型用法代碼示例。如果您正苦於以下問題:Java Inflater.end方法的具體用法?Java Inflater.end怎麽用?Java Inflater.end使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.zip.Inflater的用法示例。


在下文中一共展示了Inflater.end方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: b

import java.util.zip.Inflater; //導入方法依賴的package包/類
public static byte[] b(byte[] bArr) throws UnsupportedEncodingException, DataFormatException {
    int i = 0;
    if (bArr == null || bArr.length == 0) {
        return null;
    }
    Inflater inflater = new Inflater();
    inflater.setInput(bArr, 0, bArr.length);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    byte[] bArr2 = new byte[1024];
    while (!inflater.needsInput()) {
        int inflate = inflater.inflate(bArr2);
        byteArrayOutputStream.write(bArr2, i, inflate);
        i += inflate;
    }
    inflater.end();
    return byteArrayOutputStream.toByteArray();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:bs.java

示例4: 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

示例5: verifyLogoutOneLogoutRequestNotAttempted

import java.util.zip.Inflater; //導入方法依賴的package包/類
@Test
public void verifyLogoutOneLogoutRequestNotAttempted() throws Exception {
    final LogoutRequest logoutRequest = new DefaultLogoutRequest(TICKET_ID,
            new SimpleWebApplicationServiceImpl(TEST_URL),
            new URL(TEST_URL));
    final Event event = getLogoutEvent(Arrays.asList(logoutRequest));

    assertEquals(FrontChannelLogoutAction.REDIRECT_APP_EVENT, event.getId());
    final List<LogoutRequest> list = WebUtils.getLogoutRequests(this.requestContext);
    assertEquals(1, list.size());
    final String url = (String) event.getAttributes().get(FrontChannelLogoutAction.DEFAULT_FLOW_ATTRIBUTE_LOGOUT_URL);
    assertTrue(url.startsWith(TEST_URL + "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="));
    final byte[] samlMessage = CompressionUtils.decodeBase64ToByteArray(
            URLDecoder.decode(StringUtils.substringAfter(url, "?" + FrontChannelLogoutAction.DEFAULT_LOGOUT_PARAMETER + "="), "UTF-8"));
    final Inflater decompresser = new Inflater();
    decompresser.setInput(samlMessage);
    final byte[] result = new byte[1000];
    decompresser.inflate(result);
    decompresser.end();
    final String message = new String(result);
    assertTrue(message.startsWith("<samlp:LogoutRequest xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\""));
    assertTrue(message.contains("<samlp:SessionIndex>" + TICKET_ID + "</samlp:SessionIndex>"));
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:24,代碼來源:FrontChannelLogoutActionTests.java

示例6: 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:MUFCRyan,項目名稱:BilibiliClient,代碼行數:21,代碼來源:BiliDanmukuCompressionTools.java

示例7: 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

示例8: releaseInflater

import java.util.zip.Inflater; //導入方法依賴的package包/類
private void releaseInflater(Inflater inf) {
    synchronized (inflaters) {
        if (inflaters.size() < MAX_FLATER) {
            inf.reset();
            inflaters.add(inf);
        } else {
            inf.end();
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:11,代碼來源:ZipFileSystem.java

示例9: decompressForZlib

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * zlib decompress 2 byte
 *
 * @param bytesToDecompress
 * @return
 */
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
    byte[] returnValues = null;

    Inflater inflater = new Inflater();

    int numberOfBytesToDecompress = bytesToDecompress.length;

    inflater.setInput(bytesToDecompress, 0, numberOfBytesToDecompress);

    int numberOfBytesDecompressedSoFar = 0;
    List<Byte> bytesDecompressedSoFar = new ArrayList<>();

    try {
        while (!inflater.needsInput()) {
            byte[] bytesDecompressedBuffer = new byte[numberOfBytesToDecompress];

            int numberOfBytesDecompressedThisTime = inflater.inflate(bytesDecompressedBuffer);

            numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;

            for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
                bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
            }
        }

        returnValues = new byte[bytesDecompressedSoFar.size()];
        for (int b = 0; b < returnValues.length; b++) {
            returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
        }

    } catch (DataFormatException dfe) {
        dfe.printStackTrace();
    }

    inflater.end();
    return returnValues;
}
 
開發者ID:goutham106,項目名稱:GmArchMvvm,代碼行數:44,代碼來源:ZipHelper.java

示例10: inflate

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * Utility method to decompress a compressed byte array.
 * @param source The compressed array.
 * @param off The offset in {@code source}.
 * @param len The number of bytes to decompress from {@code source}.
 * @return The decompressed byte array.
 * @throws IOException If input array contains invalid data.
 */
public static byte[] inflate(byte[] source, int off, int len) throws IOException {
	Inflater infl = new Inflater();
	try {
		return inflate(source, off, len, infl);
	} finally {
		infl.end();
	}
}
 
開發者ID:matthieu-labas,項目名稱:JRF,代碼行數:17,代碼來源:Utils.java

示例11: ETFParser

import java.util.zip.Inflater; //導入方法依賴的package包/類
public ETFParser(byte[] data, ETFConfig config, boolean partial) {
    this.expectedVersion = config.getVersion();
    this.bert = config.isBert();
    this.loqui = config.isLoqui();

    int initialOffset = 0;
    if (Byte.toUnsignedInt(data[initialOffset]) == expectedVersion) //Skip the version number
        initialOffset++;

    if (!partial && config.isIncludingHeader()) {
        if (data[initialOffset] != HEADER)
            throw new ETFException("Missing header! Is this data malformed?").withData(data, initialOffset);
        initialOffset++;

        long uncompressedSize = wrap(data, initialOffset, 4).getInt();
        initialOffset += 4;
        
        Inflater inflater = new Inflater();
        inflater.setInput(Arrays.copyOfRange(data, initialOffset, data.length));
        
        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
            byte[] buffer = new byte[1024];
            while (inflater.getBytesWritten() != uncompressedSize) {
                int count = inflater.inflate(buffer);
                outputStream.write(buffer, 0, count);
            }
            inflater.end();
            outputStream.close();
            this.data = outputStream.toByteArray();
        } catch (Exception e) {
            throw new ETFException(e).withData(data, initialOffset);
        }
    } else {
        this.data = data;
    }
}
 
開發者ID:austinv11,項目名稱:ETF-Java,代碼行數:38,代碼來源:ETFParser.java

示例12: decompressForZlib

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * zlib decompress 2 byte
 *
 * @param bytesToDecompress
 * @return
 */
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
    byte[] returnValues = null;

    Inflater inflater = new Inflater();
    int numberOfBytesToDecompress = bytesToDecompress.length;

    inflater.setInput(
            bytesToDecompress,
            0,
            numberOfBytesToDecompress);

    int bufferSizeInBytes = numberOfBytesToDecompress;

    int numberOfBytesDecompressedSoFar = 0;
    List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();

    try {
        while (inflater.needsInput() == false) {
            byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];

            int numberOfBytesDecompressedThisTime = inflater.inflate(
                    bytesDecompressedBuffer);

            numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;

            for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
                bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
            }
        }

        returnValues = new byte[bytesDecompressedSoFar.size()];
        for (int b = 0; b < returnValues.length; b++) {
            returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
        }

    } catch (DataFormatException dfe) {
        dfe.printStackTrace();
    }

    inflater.end();

    return returnValues;
}
 
開發者ID:Wan7451,項目名稱:mvparms,代碼行數:50,代碼來源:ZipHelper.java

示例13: decompressForZlib

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * zlib decompress 2 byte
 *
 * @param bytesToDecompress
 * @return
 */
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
    byte[] returnValues = null;

    Inflater inflater = new Inflater();

    int numberOfBytesToDecompress = bytesToDecompress.length;

    inflater.setInput
            (bytesToDecompress, 0, numberOfBytesToDecompress);

    int bufferSizeInBytes = numberOfBytesToDecompress;

    int numberOfBytesDecompressedSoFar = 0;
    List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();

    try {
        while (inflater.needsInput() == false) {
            byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];

            int numberOfBytesDecompressedThisTime = inflater.inflate(bytesDecompressedBuffer);

            numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;

            for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
                bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
            }
        }

        returnValues = new byte[bytesDecompressedSoFar.size()];
        for (int b = 0; b < returnValues.length; b++) {
            returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
        }

    } catch (DataFormatException dfe) {
        dfe.printStackTrace();
    }

    inflater.end();

    return returnValues;
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:48,代碼來源:ZipUtils.java

示例14: decompressForZlib

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * zlib decompress 2 byte
 *
 * @param bytesToDecompress
 * @return
 */
public static byte[] decompressForZlib(byte[] bytesToDecompress) {
    byte[] returnValues = null;

    Inflater inflater = new Inflater();

    int numberOfBytesToDecompress = bytesToDecompress.length;

    inflater.setInput
            (
                    bytesToDecompress,
                    0,
                    numberOfBytesToDecompress
            );

    int bufferSizeInBytes = numberOfBytesToDecompress;

    int numberOfBytesDecompressedSoFar = 0;
    List<Byte> bytesDecompressedSoFar = new ArrayList<Byte>();

    try {
        while (inflater.needsInput() == false) {
            byte[] bytesDecompressedBuffer = new byte[bufferSizeInBytes];

            int numberOfBytesDecompressedThisTime = inflater.inflate
                    (
                            bytesDecompressedBuffer
                    );

            numberOfBytesDecompressedSoFar += numberOfBytesDecompressedThisTime;

            for (int b = 0; b < numberOfBytesDecompressedThisTime; b++) {
                bytesDecompressedSoFar.add(bytesDecompressedBuffer[b]);
            }
        }

        returnValues = new byte[bytesDecompressedSoFar.size()];
        for (int b = 0; b < returnValues.length; b++) {
            returnValues[b] = (byte) (bytesDecompressedSoFar.get(b));
        }

    } catch (DataFormatException dfe) {
        dfe.printStackTrace();
    }

    inflater.end();

    return returnValues;
}
 
開發者ID:VK2012,項目名稱:AppCommonFrame,代碼行數:55,代碼來源:ZipHelper.java

示例15: end

import java.util.zip.Inflater; //導入方法依賴的package包/類
/**
 * Closes the (de)compressor and discards any unprocessed input. This method should be called when
 * the (de)compressor is no longer being used. Once this method is called, the behavior
 * De/Inflater is undefined.
 *
 * @see Inflater#end
 * @see Deflater#end
 */
private static void end(Inflater inflater, Deflater deflater) {
  inflater.end();
  deflater.end();
}
 
開發者ID:lizhangqu,項目名稱:CorePatch,代碼行數:13,代碼來源:DefaultDeflateCompressionDiviner.java


注:本文中的java.util.zip.Inflater.end方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。