Code example for DataInput

Methods: readByte

0
    public void writeTo(DataOutput out) throws Exception {
        out.writeByte(type);
    } 
 
    public void readFrom(DataInput in) throws Exception {
        type=in.readByte();
    } 
 
    public String toString() {
        switch(type) {
            case REPLENISH:
                return "REPLENISH"; 
            case CREDIT_REQUEST:
                return "CREDIT_REQUEST"; 
            default: 
                return "<invalid type>"; 
        } 
    } 
}