本文整理汇总了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;
}
示例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);
}
}
示例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";
}
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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";
}
}
示例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());
}
示例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();
}
示例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()};
}
示例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();
}
示例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();
}
示例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;
}
}