当前位置: 首页>>代码示例>>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;未经允许,请勿转载。