public byte[] read(int length) throws IOException {
  byte[] data=new byte[length];
  if (length > 0) {
    int read=0;
    while (read < length) {
      int count=in.read(data,read,length - read);
      if (count < 0) {
        bytesRead+=read;
        throw new IOException("Unexpected end of input while reading a specified number of bytes");
      }
      read+=count;
    }
    bytesRead+=read;
  }
  return data;
}

public byte [ ] read ( int length ) throws IOException { byte [ ] data = new byte [ length ] ; if ( length > 0 ) { int read = 0 ; while ( read < length ) { int count = in . read ( data , read , length - read ) ; if ( count < 0 ) { bytesRead += read ; throw new IOException ( "Unexpected end of input while reading a specified number of bytes" ) ; } read += count ; } bytesRead += read ; } return data ; }
read bytes from the input stream
