本文整理汇总了Java中java.util.zip.InflaterOutputStream.write方法的典型用法代码示例。如果您正苦于以下问题:Java InflaterOutputStream.write方法的具体用法?Java InflaterOutputStream.write怎么用?Java InflaterOutputStream.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.zip.InflaterOutputStream
的用法示例。
在下文中一共展示了InflaterOutputStream.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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";
}
}
示例2: 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());
}
示例3: 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();
}
示例4: 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;
}
示例5: 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;
}
示例6: 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();
}
}
示例7: 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";
}
}
示例8: 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());
}
示例9: 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()};
}
示例10: 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();
}
示例11: 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();
}
示例12: test_write_I
import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
* @tests java.util.zip.InflaterOutputStream#write(int)
*/
public void test_write_I() throws IOException {
int length = compressToBytes(testString);
// uncompress the data stored in the compressedBytes
InflaterOutputStream ios = new InflaterOutputStream(os);
for (int i = 0; i < length; i++) {
ios.write(compressedBytes[i]);
}
String result = new String(os.toByteArray());
assertEquals(testString, result);
}
示例13: test_write_I_Illegal
import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
* @tests java.util.zip.InflaterOutputStream#write(int)
*/
public void test_write_I_Illegal() throws IOException {
// write after close
InflaterOutputStream ios = new InflaterOutputStream(os);
ios.close();
try {
ios.write(-1);
fail("Should throw IOException");
} catch (IOException e) {
// expected
}
}
示例14: compressToBytes
import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
/**
* @tests java.util.zip.InflaterOutputStream#write(byte[],int,int)
*/
public void test_write_$BII() throws IOException {
int length = compressToBytes(testString);
// uncompress the data stored in the compressedBytes
InflaterOutputStream ios = new InflaterOutputStream(os);
ios.write(compressedBytes, 0, length);
String result = new String(os.toByteArray());
assertEquals(testString, result);
}
示例15: decompress
import java.util.zip.InflaterOutputStream; //导入方法依赖的package包/类
@Override
public byte[] decompress(final byte[] data) {
if (data == null) {
return null;
}
final ByteArrayOutputStream buffer = new ByteArrayOutputStream(data.length);
final InflaterOutputStream inflaterStream = new InflaterOutputStream(buffer, new Inflater());
try {
inflaterStream.write(data);
inflaterStream.close();
buffer.close();
} catch (final IOException e) {
throw new RuntimeException("failed compressing using deflate", e);
}
return buffer.toByteArray();
}