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.cpio.CpioArchiveInputStream

    public void testCpioUnarchive() throws Exception {

final StringBuilder expected = new StringBuilder();

expected.append("./test1.xml<?xml version="1.0"?> ");

expected.append("<empty/>./test2.xml<?xml version="1.0"?> ");

expected.append("<empty/> ");





final CpioArchiveInputStream in = new CpioArchiveInputStream(new FileInputStream(getFile("bla.cpio")));

CpioArchiveEntry entry;



final StringBuilder result = new StringBuilder();

while ((entry = (CpioArchiveEntry) in.getNextEntry()) != null) {

result.append(entry.getName());

int tmp;

while ((tmp = in.read()) != -1) {

result.append((char) tmp);

}

}

in.close();

assertEquals(result.toString(), expected.toString());

}


   Like      Feedback      org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream



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