Code example for DataInput

Methods: readByte, readInt, readLong, readUTF

0
 
  /** 
   * Deserializes the object. 
   */ 
  public void readFields(DataInput in) throws IOException {
    this.version = in.readByte();
    this.httpStatusCode = in.readInt();
    this.timestamp = in.readLong();
    this.html = in.readUTF();
  } 
 
  /** 
   * Serializes this object. 
   */ 
  public void write(DataOutput out) throws IOException {
//	if(html.length() + String.valueOf(timestamp).length() + Integer.toString(httpStatusCode).length() < 32000){ 
		out.writeByte(version);
	    out.writeInt(httpStatusCode);
	    out.writeLong(timestamp);
	    out.writeUTF(html);
//	}