@Override public int read(byte b[],int off,int len) throws IOException {
  if (bb == null) {
    throw new IOException("read on a closed InputStream");
  }
  if (b == null) {
    throw new NullPointerException();
  }
 else   if (off < 0 || len < 0 || len > b.length - off) {
    throw new IndexOutOfBoundsException();
  }
 else   if (len == 0) {
    return 0;
  }
  int length=Math.min(bb.remaining(),len);
  if (length == 0) {
    return -1;
  }
  bb.get(b,off,length);
  return length;
}

@ Override public int read ( byte b [ ] , int off , int len ) throws IOException { if ( bb == null ) { throw new IOException ( "read on a closed InputStream" ) ; } if ( b == null ) { throw new NullPointerException ( ) ; } else if ( off < 0 || len < 0 || len > b . length - off ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return 0 ; } int length = Math . min ( bb . remaining ( ) , len ) ; if ( length == 0 ) { return - 1 ; } bb . get ( b , off , length ) ; return length ; }
returns a byte array from the bytebuffer . increments position ( ) .
