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


Java InflaterInputStream类代码示例

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


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

示例1: decodeByteArrayToString

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * Decode the byte[] in base64 to a string.
 *
 * @param bytes the data to encode
 * @return the new string in {@link #UTF8_ENCODING}.
 */
public static String decodeByteArrayToString(final byte[] bytes) {
    final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final byte[] buf = new byte[bytes.length];
    try (InflaterInputStream iis = new InflaterInputStream(bais)) {
        int count = iis.read(buf);
        while (count != -1) {
            baos.write(buf, 0, count);
            count = iis.read(buf);
        }
        return new String(baos.toByteArray(), Charset.forName(UTF8_ENCODING));
    } catch (final Exception e) {
        LOGGER.error("Base64 decoding failed", e);
        return null;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:CompressionUtils.java

示例2: decodeByteArrayToString

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * Decode the byte[] in base64 to a string.
 *
 * @param bytes the data to encode
 * @return the new string in {@link #UTF8_ENCODING}.
 */
public static String decodeByteArrayToString(final byte[] bytes) {
    final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final byte[] buf = new byte[bytes.length];
    try (final InflaterInputStream iis = new InflaterInputStream(bais)) {
        int count = iis.read(buf);
        while (count != -1) {
            baos.write(buf, 0, count);
            count = iis.read(buf);
        }
        return new String(baos.toByteArray(), Charset.forName(UTF8_ENCODING));
    } catch (final Exception e) {
        LOGGER.error("Base64 decoding failed", e);
        return null;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:CompressionUtils.java

示例3: decodeByteArrayToString

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * Decode the byte[] in base64 to a string.
 *
 * @param bytes the data to encode
 * @return the new string
 */
public static String decodeByteArrayToString(final byte[] bytes) {
    final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final byte[] buf = new byte[bytes.length];
    try (InflaterInputStream iis = new InflaterInputStream(bais)) {
        int count = iis.read(buf);
        while (count != -1) {
            baos.write(buf, 0, count);
            count = iis.read(buf);
        }
        return new String(baos.toByteArray(), StandardCharsets.UTF_8);
    } catch (final Exception e) {
        LOGGER.error("Base64 decoding failed", e);
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:CompressionUtils.java

示例4: decode

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
public static Schema decode(String schemaName, String[] compressedFragments) {
    try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
        for (String part : compressedFragments) {
            bos.write(BaseEncoding.base64Url().decode(part));
        }
        bos.flush();
        try (ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray())) {
            try (InflaterInputStream in = new InflaterInputStream(bin)) {
                byte[] allBinary = ByteStreams.toByteArray(in);
                String all = new String(allBinary, StandardCharsets.UTF_8);
                return new Parser()
                        .parse(all)
                        .getSchema(schemaName);
            }
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:atlascon,项目名称:travny,代码行数:20,代码来源:SchemaDecoder.java

示例5: get

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
public InputExpander get(final AlgorithmIdentifier algorithm)
{
    return new InputExpander()
    {
        public AlgorithmIdentifier getAlgorithmIdentifier()
        {
            return algorithm;
        }

        public InputStream getInputStream(InputStream comIn)
        {
            InputStream s = new InflaterInputStream(comIn);                
            if (limit >= 0)
            {
                s = new LimitedInputStream(s, limit);
            }
            return s;
        }
    };
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:ZlibExpanderProvider.java

示例6: getContent

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * @deprecated  use getContent(InputExpandedProvider)
 */
public CMSTypedStream  getContent()
    throws CMSException
{
    try
    {
        CompressedDataParser  comData = new CompressedDataParser((ASN1SequenceParser)_contentInfo.getContent(BERTags.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        ASN1OctetStringParser bytes = (ASN1OctetStringParser)content.getContent(BERTags.OCTET_STRING);

        return new CMSTypedStream(content.getContentType().toString(), new InflaterInputStream(bytes.getOctetStream()));
    }
    catch (IOException e)
    {
        throw new CMSException("IOException reading compressed content.", e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:CMSCompressedDataParser.java

示例7: getContent

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * Return the uncompressed content.
 *
 * @return the uncompressed content
 * @throws CMSException if there is an exception uncompressing the data.
 * @deprecated use getContent(InputExpanderProvider)
 */
public byte[] getContent()
    throws CMSException
{
    ContentInfo     content = comData.getEncapContentInfo();

    ASN1OctetString bytes = (ASN1OctetString)content.getContent();

    InflaterInputStream     zIn = new InflaterInputStream(bytes.getOctetStream());

    try
    {
        return CMSUtils.streamToByteArray(zIn);
    }
    catch (IOException e)
    {
        throw new CMSException("exception reading compressed stream.", e);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:CMSCompressedData.java

示例8: unzip

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
     * Unzip byte [ ].
     *
     * @param buffer             the buffer
     * @param sizeBeforeCompress the size before compress
     * @return the byte [ ]
     * @throws IOException the io exception
     */
    public static byte[] unzip ( byte[] buffer, int sizeBeforeCompress) throws IOException
    {
        InflaterInputStream inStream = new InflaterInputStream(new ByteArrayInputStream( buffer));
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        int readByte;
                byte[] buf = new byte[1024];
        try {
            while((readByte = inStream.read(buf)) != -1) {
                outStream.write(buf, 0, readByte);
            }
//            readByte = inStream.read(buf,0, sizeBeforeCompress);
//            outStream.write(buf, 0, readByte);
        } catch(Exception e)
        {
            e.printStackTrace();
        }
        byte[] ret = outStream.toByteArray();
        outStream.close();
        return ret;

    }
 
开发者ID:NeoSmartpen,项目名称:AndroidSDK2.0,代码行数:30,代码来源:OfflineByteParser.java

示例9: createDecoder

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
@Override
public OneWayCodec createDecoder() throws Exception {
    return new OneWayCodec() {
        private final Inflater inflater = new Inflater();

        @Override
        public byte[] code(final byte[] data) throws Exception {
            inflater.reset();
            final InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data), inflater);
            final ByteArrayOutputStream out = new ByteArrayOutputStream(data.length * 2);
            final byte[] b = new byte[512];
            for (;;) {
                final int i = in.read(b);
                if (i == -1) {
                    break;
                }
                out.write(b, 0, i);
            }
            return out.toByteArray();
        }
    };
}
 
开发者ID:szegedi,项目名称:spring-web-jsflow,代码行数:23,代码来源:CompressionCodec.java

示例10: unzip

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * unzip.
 * 
 * @param bytes compressed byte array.
 * @return byte uncompressed array.
 * @throws IOException
 */
public static byte[] unzip(byte[] bytes) throws IOException
{
	UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(bytes);
	UnsafeByteArrayOutputStream bos = new UnsafeByteArrayOutputStream();
	InputStream is = new InflaterInputStream(bis);
	try
	{
		IOUtils.write(is, bos);
		return bos.toByteArray();
	}
	finally
	{
		is.close();
		bis.close();
		bos.close();
	}
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:Bytes.java

示例11: zlibDeflate

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
private static String zlibDeflate(final byte[] bytes) {
    final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final InflaterInputStream iis = new InflaterInputStream(bais);
    final byte[] buf = new byte[1024];

    try {
        int count = iis.read(buf);
        while (count != -1) {
            baos.write(buf, 0, count);
            count = iis.read(buf);
        }
        return new String(baos.toByteArray());
    } catch (final Exception e) {
        return null;
    } finally {
        IOUtils.closeQuietly(iis);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:20,代码来源:GoogleAccountsService.java

示例12: DecompressByteArrayToString

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
public static String DecompressByteArrayToString(byte[] bytes) {
    InputStream inputStream = new InflaterInputStream(new ByteArrayInputStream(bytes));
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try {
        byte[] buffer = new byte[8192];
        int length;

        while ((length = inputStream.read(buffer)) > 0) {
            byteArrayOutputStream.write(buffer, 0, length);
        }

        return new String(byteArrayOutputStream.toByteArray(), "UTF-8");
    } catch (IOException exception) {
        Logger.getInstance().Error(TAG, exception.getMessage());
        return "";
    }
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:18,代码来源:Tools.java

示例13: read

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
public static Area read(Save save, int x, int z) {
	FileHandle file = file(save, x, z);

	if (!file.exists()) {
		// Log.warning("Area does not exist");
		return null;
	}

	Inflater inflater = inflaterThreadLocal.get();

	try {
		inflater.reset();
		InputStream inputStream = file.read(8192);
		InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream, inflater);
		BufferedInputStream bufferedInputStream = new BufferedInputStream(inflaterInputStream);
		DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);
		Area area = new Area(x, z);
		area.read(dataInputStream);
		dataInputStream.close();
		return area;
	} catch (Exception e) {
		Log.error("Failed to read area " + x + "," + z, e);
		return null;
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:26,代码来源:SaveAreaIO.java

示例14: decodeMessage

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
/**
 * Base64 decodes the SAML message and then decompresses the message.
 * 
 * @param message Base64 encoded, DEFALTE compressed, SAML message
 * 
 * @return the SAML message
 * 
 * @throws MessageDecodingException thrown if the message can not be decoded
 */
protected InputStream decodeMessage(String message) throws MessageDecodingException {
    log.debug("Base64 decoding and inflating SAML message");

    byte[] decodedBytes = Base64.decode(message);
    if(decodedBytes == null){
        log.error("Unable to Base64 decode incoming message");
        throw new MessageDecodingException("Unable to Base64 decode incoming message");
    }
    
    try {
        ByteArrayInputStream bytesIn = new ByteArrayInputStream(decodedBytes);
        InflaterInputStream inflater = new InflaterInputStream(bytesIn, new Inflater(true));
        return inflater;
    } catch (Exception e) {
        log.error("Unable to Base64 decode and inflate SAML message", e);
        throw new MessageDecodingException("Unable to Base64 decode and inflate SAML message", e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HTTPRedirectDeflateDecoder.java

示例15: inflate

import java.util.zip.InflaterInputStream; //导入依赖的package包/类
public static byte[] inflate(InputStream stream) throws IOException {
    InflaterInputStream inputStream = new InflaterInputStream(stream);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    byte[] buffer = new byte[1024];
    int length;

    try {
        while ((length = inputStream.read(buffer)) != -1) {
            outputStream.write(buffer, 0, length);
        }
    } finally {
        buffer = outputStream.toByteArray();
        outputStream.flush();
        outputStream.close();
        inputStream.close();
    }

    return buffer;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:20,代码来源:Zlib.java


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