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.archivers.zip.ZipEncoding

    private static void assertUnicodeName(final ZipArchiveEntry ze,

final String expectedName,

final String encoding)

throws IOException {

if (!expectedName.equals(ze.getName())) {

final UnicodePathExtraField ucpf = findUniCodePath(ze);

assertNotNull(ucpf);



final ZipEncoding enc = ZipEncodingHelper.getZipEncoding(encoding);

final ByteBuffer ne = enc.encode(ze.getName());



final CRC32 crc = new CRC32();

crc.update(ne.array(), ne.arrayOffset(),

ne.limit() - ne.position());



assertEquals(crc.getValue(), ucpf.getNameCRC32());

assertEquals(expectedName, new String(ucpf.getUnicodeName(),

CharsetNames.UTF_8));

}

}


   Like      Feedback      org.apache.commons.compress.archivers.zip.ZipEncoding



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