@Test public void shouldHavBZip2CompatibleOutput() throws IOException { BZip2Compressor<String> compressor = new BZip2Compressor<>(String::getBytes); String origString = "somestring"; try (ByteArrayInputStream inputStream = new ByteArrayInputStream(compressor.compress(origString)); BZip2CompressorInputStream bzip2Input = new BZip2CompressorInputStream(inputStream); BufferedReader reader = new BufferedReader(new InputStreamReader(bzip2Input))) { Assert.assertEquals(origString, reader.readLine()); } }
@Override public byte[] compress(T option) throws IOException { ByteArrayOutputStream compressedStream = new ByteArrayOutputStream(); try (BZip2CompressorOutputStream bzip2Output = new BZip2CompressorOutputStream(compressedStream)) { bzip2Output.write(byteConverter.toByte(option)); } return compressedStream.toByteArray(); }
BZip2Compressor implements OptionCompressor<T> { @Override public byte[] compress(T option) throws IOException { ByteArrayOutputStream compressedStream = new ByteArrayOutputStream(); try (BZip2CompressorOutputStream bzip2Output = new BZip2CompressorOutputStream(compressedStream)) { bzip2Output.write(byteConverter.toByte(option)); } return compressedStream.toByteArray(); } }
BZip2Compressor implements OptionCompressor<T> { @Override public byte[] compress(T option) throws IOException { ByteArrayOutputStream compressedStream = new ByteArrayOutputStream(); try (BZip2CompressorOutputStream bzip2Output = new BZip2CompressorOutputStream(compressedStream)) { bzip2Output.write(byteConverter.toByte(option)); } return compressedStream.toByteArray(); } BZip2Compressor(OptionByteConverter<T> byteConverter); }
BZip2Compressor implements OptionCompressor<T> { @Override public byte[] compress(T option) throws IOException { ByteArrayOutputStream compressedStream = new ByteArrayOutputStream(); try (BZip2CompressorOutputStream bzip2Output = new BZip2CompressorOutputStream(compressedStream)) { bzip2Output.write(byteConverter.toByte(option)); } return compressedStream.toByteArray(); } BZip2Compressor(OptionByteConverter<T> byteConverter); @Override byte[] compress(T option); }
BZip2Compressor implements OptionCompressor<T> { @Override public byte[] compress(T option) throws IOException { ByteArrayOutputStream compressedStream = new ByteArrayOutputStream(); try (BZip2CompressorOutputStream bzip2Output = new BZip2CompressorOutputStream(compressedStream)) { bzip2Output.write(byteConverter.toByte(option)); } return compressedStream.toByteArray(); } BZip2Compressor(OptionByteConverter<T> byteConverter); @Override byte[] compress(T option);  }