Share

Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream

    private void testExtraFlags(final int compressionLevel, final int flag) throws Exception {

final FileInputStream fis = new FileInputStream(getFile("test3.xml"));

byte[] content;

try {

content = IOUtils.toByteArray(fis);

} finally {

fis.close();

}



final ByteArrayOutputStream bout = new ByteArrayOutputStream();



final GzipParameters parameters = new GzipParameters();

parameters.setCompressionLevel(compressionLevel);

final GzipCompressorOutputStream out = new GzipCompressorOutputStream(bout, parameters);

IOUtils.copy(new ByteArrayInputStream(content), out);

out.flush();

out.close();



assertEquals("extra flags (XFL)", flag, bout.toByteArray()[8]);

}


   Like      Feedback      org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus