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 {



final ByteArrayOutputStream bout = new ByteArrayOutputStream();

final GzipParameters parameters = new GzipParameters();


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

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



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
Enter your email address:
Delivered by FeedBurner

comments powered by Disqus