CoderUtil { static ByteBuffer resetBuffer(ByteBuffer buffer, int len) { int pos = buffer.position(); buffer.put(getEmptyChunk(len), 0, len); buffer.position(pos); return buffer; } private  CoderUtil();   }
@Test public void testResetBuffer() { ByteBuffer buf = ByteBuffer.allocate(chunkSize * 2).putInt(1234); buf.position(0); ByteBuffer ret = CoderUtil.resetBuffer(buf, chunkSize); for (int i = 0; i < chunkSize; i++) { assertEquals(0, ret.getInt(i)); } byte[] inputs = ByteBuffer.allocate(numInputs) .putInt(1234).array(); CoderUtil.resetBuffer(inputs, 0, numInputs); for (int i = 0; i < numInputs; i++) { assertEquals(0, inputs[i]); } }