Share

Search Java Code Snippets


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





#Java - Code Snippets for '#Org.apache.commons.compress.utils.CountingOutputStream' - 1 code snippet(s) found

 Sample 1. Code Sample / Example / Snippet of org.apache.commons.compress.utils.CountingOutputStream

    public void output() throws Exception {

final ByteArrayOutputStream bos = new ByteArrayOutputStream();

final CountingOutputStream o = new CountingOutputStream(bos);

o.write(1);

assertEquals(1, o.getBytesWritten());

o.write(new byte[] { 2, 3 });

assertEquals(3, o.getBytesWritten());

o.write(new byte[] { 2, 3, 4, 5, }, 2, 1);

assertEquals(4, o.getBytesWritten());

o.count(-1);

assertEquals(4, o.getBytesWritten());

o.count(-2);

assertEquals(2, o.getBytesWritten());

o.close();

assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bos.toByteArray());

}


   Like      Feedback      org.apache.commons.compress.utils.CountingOutputStream



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