public static final void readFully(InputStream i,byte b[],int off,int len) throws IOException {
  if (len < 0) {
    throw new IndexOutOfBoundsException();
  }
  int n=0;
  while (n < len) {
    int count=i.read(b,off + n,len - n);
    if (count < 0) {
      throw new EOFException();
    }
    n+=count;
  }
}

public static final void readFully ( InputStream i , byte b [ ] , int off , int len ) throws IOException { if ( len < 0 ) { throw new IndexOutOfBoundsException ( ) ; } int n = 0 ; while ( n < len ) { int count = i . read ( b , off + n , len - n ) ; if ( count < 0 ) { throw new EOFException ( ) ; } n += count ; } }
the read fully method from data input stream is very useful for all types of streams . . .
