Java Code Examples for java.util.zip.InflaterOutputStream#write()
The following examples show how to use
java.util.zip.InflaterOutputStream#write() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Memory.java From Much-Assembly-Required with GNU General Public License v3.0 | 6 votes |
public Memory(Document document) { String zipBytesStr = (String) document.get("zipBytes"); if (zipBytesStr != null) { byte[] compressedBytes = Base64.getDecoder().decode((String) document.get("zipBytes")); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Inflater decompressor = new Inflater(true); InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(baos, decompressor); inflaterOutputStream.write(compressedBytes); inflaterOutputStream.close(); setBytes(baos.toByteArray()); } catch (IOException e) { e.printStackTrace(); } } else { LogManager.LOGGER.severe("Memory was manually deleted"); words = new char[GameServer.INSTANCE.getConfig().getInt("memory_size")]; } }
Example 2
Source File: CompressedPacketSenderTest.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
public boolean nextPayload() throws IOException { if (this.offset == this.packetData.length) { return false; } // read compressed packet header this.compressedPayloadLen = NativeUtils.decodeMysqlThreeByteInteger(this.packetData, this.offset); this.compressedSequenceId = this.packetData[this.offset + 3]; this.uncompressedPayloadLen = NativeUtils.decodeMysqlThreeByteInteger(this.packetData, this.offset + 4); this.offset += CompressedPacketSender.COMP_HEADER_LENGTH; if (this.uncompressedPayloadLen == 0) { // uncompressed packet this.payload = java.util.Arrays.copyOfRange(this.packetData, this.offset, this.offset + this.compressedPayloadLen); } else { // uncompress payload InflaterOutputStream inflater = new InflaterOutputStream(this.decompressedStream); inflater.write(this.packetData, this.offset, this.compressedPayloadLen); inflater.finish(); inflater.flush(); this.payload = this.decompressedStream.toByteArray(); this.decompressedStream.reset(); } this.offset += this.compressedPayloadLen; return true; }
Example 3
Source File: DeflateCompressor.java From ob1k with Apache License 2.0 | 6 votes |
@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(); }
Example 4
Source File: DigestUtils.java From JobX with Apache License 2.0 | 5 votes |
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"; } }
Example 5
Source File: DigestUtils.java From JobX with Apache License 2.0 | 5 votes |
public static String decompressData(String encdata, String charset) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); InflaterOutputStream zos = new InflaterOutputStream(bos); zos.write(getdeBASE64inCodec(encdata)); zos.close(); return new String(bos.toByteArray(), charset); } catch (Exception ex) { ex.printStackTrace(); return "UNZIP_ERR"; } }
Example 6
Source File: mdBase.java From mdict-java with GNU General Public License v3.0 | 5 votes |
public static byte[] zlib_decompress(byte[] encdata,int offset,int size) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); InflaterOutputStream inf = new InflaterOutputStream(out); inf.write(encdata,offset, size); inf.close(); return out.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); //show(emptyStr); return "ERR".getBytes(); } }
Example 7
Source File: mdBase.java From mdict-java with GNU General Public License v3.0 | 5 votes |
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(); } }
Example 8
Source File: BU.java From mdict-java with GNU General Public License v3.0 | 5 votes |
@Deprecated public static byte[] zlib_decompress(byte[] encdata,int offset,int ln) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); InflaterOutputStream inf = new InflaterOutputStream(out); inf.write(encdata,offset, ln); inf.close(); return out.toByteArray(); } catch (Exception ex) { ex.printStackTrace(); return "ERR".getBytes(); } }
Example 9
Source File: DigestUtils.java From opencron with Apache License 2.0 | 5 votes |
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"; } }
Example 10
Source File: DigestUtils.java From opencron with Apache License 2.0 | 5 votes |
public static String decompressData(String encdata, String charset) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); InflaterOutputStream zos = new InflaterOutputStream(bos); zos.write(getdeBASE64inCodec(encdata)); zos.close(); return new String(bos.toByteArray(), charset); } catch (Exception ex) { ex.printStackTrace(); return "UNZIP_ERR"; } }
Example 11
Source File: GelfUdpAppenderTest.java From logback-gelf with GNU Lesser General Public License v2.1 | 5 votes |
private JsonNode receiveCompressedMessage() { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final InflaterOutputStream inflaterOutputStream = new InflaterOutputStream(bos); try { inflaterOutputStream.write(receive()); inflaterOutputStream.close(); return new ObjectMapper().readTree(bos.toByteArray()); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example 12
Source File: Woff1Font.java From FontVerter with GNU Lesser General Public License v3.0 | 5 votes |
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(); }
Example 13
Source File: SAMLResponseExtractor.java From development with Apache License 2.0 | 5 votes |
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()); }
Example 14
Source File: InflaterOutputStreamTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * 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 } }