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.archivers.sevenz.SevenZOutputFile

    public void testReadingBackLZMA2DictSize() throws Exception {

final File output = new File(dir, "lzma2-dictsize.7z");

final SevenZOutputFile outArchive = new SevenZOutputFile(output);

try {

outArchive.setContentMethods(Arrays.asList(new SevenZMethodConfiguration(SevenZMethod.LZMA2, 1 << 20)));

final SevenZArchiveEntry entry = new SevenZArchiveEntry();

entry.setName("foo.txt");

outArchive.putArchiveEntry(entry);

outArchive.write(new byte[] { 'A' });

outArchive.closeArchiveEntry();

} finally {

outArchive.close();

}



final SevenZFile archive = new SevenZFile(output);

try {

final SevenZArchiveEntry entry = archive.getNextEntry();

final SevenZMethodConfiguration m = entry.getContentMethods().iterator().next();

assertEquals(SevenZMethod.LZMA2, m.getMethod());

assertEquals(1 << 20, m.getOptions());

} finally {

archive.close();

}

}


   Like      Feedback      org.apache.commons.compress.archivers.sevenz.SevenZOutputFile



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