@Test public void testCrcOutputStream() throws IOException { byte[] buf = new byte[4000]; ByteBufferOutputStream stream = new ByteBufferOutputStream(ByteBuffer.wrap(buf)); CrcOutputStream crcStream = new CrcOutputStream(stream); byte[] bufOutput = new byte[4000]; new Random().nextBytes(bufOutput); try { crcStream.write(bufOutput); } catch (IOException e) { Assert.assertTrue(false); } Assert.assertArrayEquals(buf, bufOutput); long value1 = crcStream.getValue(); stream = new ByteBufferOutputStream(ByteBuffer.wrap(buf)); crcStream = new CrcOutputStream(stream); try { crcStream.write(bufOutput[0]); crcStream.write(bufOutput, 1, 3999); } catch (IOException e) { Assert.assertTrue(false); } Assert.assertArrayEquals(buf, bufOutput); long value2 = crcStream.getValue(); Assert.assertEquals(value1, value2); bufOutput[0] = (byte) (~bufOutput[0]); stream = new ByteBufferOutputStream(ByteBuffer.wrap(buf)); crcStream = new CrcOutputStream(stream); try { crcStream.write(bufOutput[0]); crcStream.write(bufOutput, 1, 3999); } catch (IOException e) { Assert.assertTrue(false); } Assert.assertArrayEquals(buf, bufOutput); long value3 = crcStream.getValue(); Assert.assertFalse(value2 == value3); crcStream.close(); }
public CrcOutputStream(OutputStream out) { this(new Crc32(), out); }
CrcOutputStream extends OutputStream { public CrcOutputStream(OutputStream out) { this(new Crc32(), out); } }
CrcOutputStream extends OutputStream { public CrcOutputStream(OutputStream out) { this(new Crc32(), out); } CrcOutputStream(OutputStream out);  CrcOutputStream(Crc32 crc, OutputStream out); }
CrcOutputStream extends OutputStream { public CrcOutputStream(OutputStream out) { this(new Crc32(), out); } CrcOutputStream(OutputStream out);  CrcOutputStream(Crc32 crc, OutputStream out); @Override void write(int b); @Override void write(byte b[]); @Override void write(byte b[], int off, int len); @Override void close(); long getValue(); }
CrcOutputStream extends OutputStream { public CrcOutputStream(OutputStream out) { this(new Crc32(), out); } CrcOutputStream(OutputStream out);  CrcOutputStream(Crc32 crc, OutputStream out); @Override void write(int b); @Override void write(byte b[]); @Override void write(byte b[], int off, int len); @Override void close(); long getValue();  }