public static void readFully(InputStream in,byte buf[],int off,int len) throws IOException {
  int toRead=len;
  while (toRead > 0) {
    int ret=in.read(buf,off,toRead);
    if (ret < 0) {
      throw new IOException("Premature EOF from inputStream");
    }
    toRead-=ret;
    off+=ret;
  }
}

public static void readFully ( InputStream in , byte buf [ ] , int off , int len ) throws IOException { int toRead = len ; while ( toRead > 0 ) { int ret = in . read ( buf , off , toRead ) ; if ( ret < 0 ) { throw new IOException ( "Premature EOF from inputStream" ) ; } toRead -= ret ; off += ret ; } }
does the readfully based on the input read .
