### Question:
DataOutputBuffer extends DataOutputStream { public void write(DataInput in, int length) throws IOException { buffer.write(in, length); } DataOutputBuffer();  DataOutputBuffer(int size); private  DataOutputBuffer(Buffer buffer); byte[] getData(); int getLength(); DataOutputBuffer reset(); void write(DataInput in, int length); void writeTo(OutputStream out);  }### Answer:
@Test public void testWrite() throws Exception { DataOutputBuffer outBuffer = new DataOutputBuffer(1024); outBuffer.write(tests); assertEquals(outBuffer.getLength(), tests.length); assertEquals(new String(outBuffer.getData(), 0, outBuffer.getLength()), new String(tests, 0, tests.length)); outBuffer.close(); }