Code example for DataInput

Methods: readFully, readInt

0
        return r;
    } 
 
    @Override 
    void read(final DataInput in) throws IOException {
        final int s = in.readInt();
        final byte[] p = new byte[s];
        in.readFully(p);
        payload = p;
    } 
 
    @Override 
    void write(final DataOutput out) throws IOException {
        out.writeInt(payload.length);
        out.write(payload);
    } 
 
}