TypedBytesWritable extends BytesWritable { public void setValue(Object obj) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); TypedBytesOutput tbo = TypedBytesOutput.get(new DataOutputStream(baos)); tbo.write(obj); byte[] bytes = baos.toByteArray(); set(bytes, 0, bytes.length); } catch (IOException e) { throw new RuntimeException(e); } } TypedBytesWritable();  TypedBytesWritable(byte[] bytes); void setValue(Object obj); Object getValue(); Type getType(); String toString();  }
@Test public void testIO() throws IOException { TypedBytesWritable tbw = new TypedBytesWritable(); tbw.setValue(12345); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutput dout = new DataOutputStream(baos); tbw.write(dout); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInput din = new DataInputStream(bais); TypedBytesWritable readTbw = new TypedBytesWritable(); readTbw.readFields(din); assertEquals(tbw, readTbw); }