@Override public int read(byte[] buffer,int offset,int length){
  if (currentPos >= data.length) {
    if (isFinal) {
      return -1;
    }
 else {
      try {
        Thread.sleep(20);
      }
 catch (      InterruptedException e) {
      }
    }
  }
  int i=0;
  for (i=0; i < length & (currentPos + i) < data.length; i++) {
    buffer[offset + i]=data[currentPos + i];
  }
  currentPos+=i;
  return i;
}

@ Override public int read ( byte [ ] buffer , int offset , int length ) { if ( currentPos >= data . length ) { if ( isFinal ) { return - 1 ; } else { try { Thread . sleep ( 20 ) ; } catch ( InterruptedException e ) { } } } int i = 0 ; for ( i = 0 ; i < length & ( currentPos + i ) < data . length ; i ++ ) { buffer [ offset + i ] = data [ currentPos + i ] ; } currentPos += i ; return i ; }
reads a buffer of data from the stream
