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


Java InflaterOutputStream类代码示例

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


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

示例1: decompressZlib

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static byte[] decompressZlib(byte[] input) {
    try {
        Inflater decompress = new Inflater();
        decompress.setInput(input);
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(byteArrayOutputStream, decompress);
        inflaterOutputStream.flush();
        return byteArrayOutputStream.toByteArray();
    } catch (Exception e) {
        System.out.println("An error occured while decompressing data");
        System.exit(-2);
    }
    return null;
}
 
开发者ID:clienthax,项目名称:Crunched,代码行数:15,代码来源:Utils.java

示例2: inflate

import java.util.zip.InflaterOutputStream; //导入依赖的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</code> encoding
 */
public static String inflate(final byte[] bytes) {
    try (ByteArrayInputStream inb = new ByteArrayInputStream(bytes);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         InflaterOutputStream ios = new InflaterOutputStream(out);) {
        IOUtils.copy(inb, ios);
        return new String(out.toByteArray(), UTF8_ENCODING);
    } catch (final Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:CompressionUtils.java

示例3: decompressData

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static String decompressData(String encdata) {
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InflaterOutputStream zos = new InflaterOutputStream(bos);
        zos.write(getdeBASE64inCodec(encdata));
        zos.close();
        return new String(bos.toByteArray());
    } catch (Exception ex) {
        ex.printStackTrace();
        return "UNZIP_ERR";
    }
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:13,代码来源:DigestUtils.java

示例4: inflate

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
private String inflate(byte[] decodedBytes) throws IOException {
    ByteArrayOutputStream inflatedBytes = new ByteArrayOutputStream();
    Inflater inflater = new Inflater(true);
    InflaterOutputStream inflaterStream = new InflaterOutputStream(inflatedBytes, inflater);
    inflaterStream.write(decodedBytes);
    inflaterStream.finish();
    return new String(inflatedBytes.toByteArray());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:9,代码来源:SAMLResponseExtractor.java

示例5: decompressData

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static byte[] decompressData(String encdata) throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    InflaterOutputStream zos = new InflaterOutputStream(bos);
    byte[] bs = decryptBASE64(encdata);
    zos.write(bs);
    zos.close();
    return bos.toByteArray();
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:9,代码来源:CryptUtil.java

示例6: deserialize

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static TileMap deserialize(JSONObject object) {

        TileMap tileMap = new TileMap(World.WORLD_SIZE, World.WORLD_SIZE);

        byte[] compressedBytes = Base64.getDecoder().decode((String) object.get("z"));

        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Inflater decompressor = new Inflater(true);
            InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(baos, decompressor);
            inflaterOutputStream.write(compressedBytes);
            inflaterOutputStream.close();

            byte[] terrain = baos.toByteArray();

            for (int x = 0; x < World.WORLD_SIZE; x++) {
                for (int y = 0; y < World.WORLD_SIZE; y++) {
                    tileMap.tiles[x][y] = terrain[x * World.WORLD_SIZE + y];
                }
            }

            return tileMap;


        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:31,代码来源:TileMap.java

示例7: deserialize

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static Memory deserialize(DBObject obj) {

        Memory memory = new Memory(0);

        String zipBytesStr = (String) obj.get("zipBytes");

        if (zipBytesStr != null) {
            byte[] compressedBytes = Base64.getDecoder().decode((String) obj.get("zipBytes"));

            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                Inflater decompressor = new Inflater(true);
                InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(baos, decompressor);
                inflaterOutputStream.write(compressedBytes);
                inflaterOutputStream.close();

                memory.setBytes(baos.toByteArray());

            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            LogManager.LOGGER.severe("Memory was manually deleted");
            memory = new Memory(GameServer.INSTANCE.getConfig().getInt("memory_size"));
        }

        return memory;
    }
 
开发者ID:simon987,项目名称:Much-Assembly-Required,代码行数:29,代码来源:Memory.java

示例8: zlib_decompress

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static byte[] zlib_decompress(byte[] encdata,int offset) {
 try {
   ByteArrayOutputStream out = new ByteArrayOutputStream(); 
   InflaterOutputStream inf = new InflaterOutputStream(out); 
   inf.write(encdata,offset, encdata.length-offset); 
   inf.close(); 
   return out.toByteArray(); 
  } catch (Exception ex) {
  	ex.printStackTrace(); 
  	return "ERR".getBytes(); 
  }
}
 
开发者ID:KnIfER,项目名称:mdict-parser-java,代码行数:13,代码来源:mdictRes.java

示例9: zlib_decompress_to_str

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static String zlib_decompress_to_str(byte[] encdata,int offset) {
 try {
   ByteArrayOutputStream out = new ByteArrayOutputStream(); 
   InflaterOutputStream inf = new InflaterOutputStream(out); 
   inf.write(encdata,offset, encdata.length-offset); 
   inf.close(); 
   return out.toString("ASCII");
  } catch (Exception ex) {
  	ex.printStackTrace(); 
  	return "ERR"; 
  }
}
 
开发者ID:KnIfER,项目名称:mdict-parser-java,代码行数:13,代码来源:mdict.java

示例10: receiveCompressedMessage

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
private JsonNode receiveCompressedMessage() throws IOException {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    final InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(bos);

    inflaterOutputStream.write(server.getReceivedData());
    inflaterOutputStream.close();

    return new ObjectMapper().readTree(bos.toByteArray());
}
 
开发者ID:osiegmar,项目名称:logback-gelf,代码行数:10,代码来源:GelfUdpAppenderTest.java

示例11: inflate

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
private byte[] inflate(byte[] uncompressed) {
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    try (InflaterOutputStream deflaterOutputStream = new InflaterOutputStream(byteArrayOutputStream)) {
        deflaterOutputStream.write(uncompressed);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return byteArrayOutputStream.toByteArray();
}
 
开发者ID:pitchpoint-solutions,项目名称:sfs,代码行数:10,代码来源:DumpFileWriter.java

示例12: inflate

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
private Object[] inflate(byte[] data) throws LuaException {
	if (data.length >= Config.APIs.Data.limit) throw new LuaException("Data is too long");

	ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
	InflaterOutputStream inos = new InflaterOutputStream(baos, new Inflater(true));
	try {
		inos.write(data);
		inos.finish();
	} catch (IOException e) {
		throw LuaHelpers.rewriteException(e, "Inflating error");
	}

	return new Object[]{baos.toByteArray()};
}
 
开发者ID:SquidDev-CC,项目名称:CCTweaks-Lua,代码行数:15,代码来源:DataAPI.java

示例13: readCompressedData

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
protected void readCompressedData(byte[] readData) throws IOException {
    if (readData.length == originalLength) {
        this.tableData = readData;
        return;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    InflaterOutputStream compressStream = new InflaterOutputStream(out);
    compressStream.write(readData);
    compressStream.close();

    tableData = out.toByteArray();
}
 
开发者ID:m-abboud,项目名称:FontVerter,代码行数:14,代码来源:Woff1Font.java

示例14: gunzipBytes

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
public static byte[] gunzipBytes(byte[] compressedBytes) throws IOException
{
    ByteArrayOutputStream bos = new ByteArrayOutputStream((int)(compressedBytes.length * 1.5));
    InflaterOutputStream dos = new InflaterOutputStream(bos);
    dos.write(compressedBytes);
    dos.close();
    return bos.toByteArray();
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:9,代码来源:CompressionService.java

示例15: onBinaryMessage

import java.util.zip.InflaterOutputStream; //导入依赖的package包/类
@Override
public void onBinaryMessage(WebSocket websocket, byte[] binary) throws IOException, DataFormatException
{
    if (!onBufferMessage(binary))
        return;
    //Thanks to ShadowLordAlpha and Shredder121 for code and debugging.
    //Get the compressed message and inflate it
    final int size = readBuffer != null ? readBuffer.size() : binary.length;
    ByteArrayOutputStream out = new ByteArrayOutputStream(size * 2);
    try (InflaterOutputStream decompressor = new InflaterOutputStream(out, zlibContext))
    {
        if (readBuffer != null)
            readBuffer.writeTo(decompressor);
        else
            decompressor.write(binary);
        // send the inflated message to the TextMessage method
        onTextMessage(websocket, out.toString("UTF-8"));
    }
    catch (IOException e)
    {
        throw (DataFormatException) new DataFormatException("Malformed").initCause(e);
    }
    finally
    {
        readBuffer = null;
    }
}
 
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:28,代码来源:WebSocketClient.java


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