@Test public void testDecompress() throws CompressionException { String data = "Hello World!"; DeflateCompressor compressor = new DeflateCompressor(); byte[] compressed = compressor.compress(data, null); String decompressed = new String(((ByteArrayOutputStream)compressor.decompress(new ByteArrayInputStream(compressed))).toByteArray()); Assert.assertEquals(data, decompressed, "DeflateCompressor : given data did not decompress."); }
public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new InflaterInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { throw new CompressionException("IOException while decompress the data using Deflate compression.", ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }
DeflateCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new InflaterInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { throw new CompressionException("IOException while decompress the data using Deflate compression.", ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } } }
DeflateCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new InflaterInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { throw new CompressionException("IOException while decompress the data using Deflate compression.", ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  }
DeflateCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new InflaterInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { throw new CompressionException("IOException while decompress the data using Deflate compression.", ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  byte[] compress(final String data, byte[] uploadFile); OutputStream decompress(final InputStream in); }
DeflateCompressor implements ICompressor { public OutputStream decompress(final InputStream in) throws CompressionException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { InputStream inflater = new InflaterInputStream(in); byte[] bbuf = new byte[LENGTH_256]; while (true) { int r = inflater.read(bbuf); if (r < 0) { break; } baos.write(bbuf, 0, r); } return baos; } catch (IOException ioe) { throw new CompressionException("IOException while decompress the data using Deflate compression.", ioe); } finally { if (baos != null) { try { baos.close(); } catch (IOException e) { LOG.error("Unable to close ByteArrayOutputStream."); } } } }  byte[] compress(final String data, byte[] uploadFile); OutputStream decompress(final InputStream in);  }