@Test public void write() throws Exception { try (Crc32Writer writer = new Crc32Writer(fileWriter)) { ByteBuffer buf = ByteBuffer.wrap(data); while (buf.hasRemaining()) writer.write(buf); assertEquals(expectedCrc, writer.getCrc32()); } }
@Override public int write(ByteBuffer data) throws IOException { final ByteBuffer copy = data.asReadOnlyBuffer(); final int wlen = out.write(data); copy.limit(copy.position() + wlen); crc32.update(copy); return wlen; }
Crc32Writer implements FileWriter { @Override public int write(ByteBuffer data) throws IOException { final ByteBuffer copy = data.asReadOnlyBuffer(); final int wlen = out.write(data); copy.limit(copy.position() + wlen); crc32.update(copy); return wlen; } }
Crc32Writer implements FileWriter { @Override public int write(ByteBuffer data) throws IOException { final ByteBuffer copy = data.asReadOnlyBuffer(); final int wlen = out.write(data); copy.limit(copy.position() + wlen); crc32.update(copy); return wlen; }  }
Crc32Writer implements FileWriter { @Override public int write(ByteBuffer data) throws IOException { final ByteBuffer copy = data.asReadOnlyBuffer(); final int wlen = out.write(data); copy.limit(copy.position() + wlen); crc32.update(copy); return wlen; }  int getCrc32(); @Override int write(ByteBuffer data); @Override void close(); @Override ByteBuffer allocateByteBuffer(int size); }
Crc32Writer implements FileWriter { @Override public int write(ByteBuffer data) throws IOException { final ByteBuffer copy = data.asReadOnlyBuffer(); final int wlen = out.write(data); copy.limit(copy.position() + wlen); crc32.update(copy); return wlen; }  int getCrc32(); @Override int write(ByteBuffer data); @Override void close(); @Override ByteBuffer allocateByteBuffer(int size); static final int CRC_LEN; }