public void readData(DataInput din) throws IOException {
  int byteCount=din.readUnsignedByte();
  records=new RecordRequest[0];
  for (int offset=1; offset + 7 < byteCount; ) {
    int function=din.readUnsignedByte();
    int file=din.readUnsignedShort();
    int record=din.readUnsignedShort();
    int count=din.readUnsignedShort();
    offset+=7;
    if (function != 6) {
      throw new IOException();
    }
    if (record < 0 || record >= 10000) {
      throw new IOException();
    }
    if (count < 0 || count >= 126) {
      throw new IOException();
    }
    short registers[]=new short[count];
    for (int j=0; j < count; j++) {
      registers[j]=din.readShort();
      offset+=2;
    }
    RecordRequest dummy[]=new RecordRequest[records.length + 1];
    if (records.length > 0) {
      System.arraycopy(records,0,dummy,0,records.length);
    }
    records=dummy;
    records[records.length - 1]=new RecordRequest(file,record,registers);
  }
}

public void readData ( DataInput din ) throws IOException { int byteCount = din . readUnsignedByte ( ) ; records = new RecordRequest [ 0 ] ; for ( int offset = 1 ; offset + 7 < byteCount ; ) { int function = din . readUnsignedByte ( ) ; int file = din . readUnsignedShort ( ) ; int record = din . readUnsignedShort ( ) ; int count = din . readUnsignedShort ( ) ; offset += 7 ; if ( function != 6 ) { throw new IOException ( ) ; } if ( record < 0 || record >= 10000 ) { throw new IOException ( ) ; } if ( count < 0 || count >= 126 ) { throw new IOException ( ) ; } short registers [ ] = new short [ count ] ; for ( int j = 0 ; j < count ; j ++ ) { registers [ j ] = din . readShort ( ) ; offset += 2 ; } RecordRequest dummy [ ] = new RecordRequest [ records . length + 1 ] ; if ( records . length > 0 ) { System . arraycopy ( records , 0 , dummy , 0 , records . length ) ; } records = dummy ; records [ records . length - 1 ] = new RecordRequest ( file , record , registers ) ; } }
readdata - - convert the byte stream into a request .
