private void storeMetadata() throws IOException {
  long pos=0;
  int position=0;
  int bytesToRead=readSize;
  if (raf.getLen() < readSize) {
    position=0;
    bytesToRead=(int)raf.getLen();
  }
 else {
    position=(int)(raf.getLen() - readSize);
  }
  while (true) {
    raf.seek(position);
    byte[] bytes=new byte[bytesToRead];
    int lastIndex=0;
    int totalLen=0;
    while (true) {
      int len=raf.read(bytes,lastIndex,bytesToRead - lastIndex);
      totalLen+=len;
      if (totalLen != bytesToRead) {
        lastIndex=totalLen;
      }
 else {
        break;
      }
    }
    int headerIndex=lastIndexOf(bytes,headerbytes,0,bytesToRead - 1);
    if (headerIndex == -1) {
      if (position == 0) {
        raf.seek(0);
        break;
      }
      bytesToRead=position;
      if (bytesToRead > readSize) {
        bytesToRead=readSize;
      }
      position-=(readSize - headerbytes.length);
      if (position < 0) {
        position=0;
      }
    }
 else {
      raf.seek(position + headerIndex + headerbytes.length);
      ByteArrayOutputStream bos=new ByteArrayOutputStream();
      while (true) {
        int i=raf.read();
        if (i == 0) {
          break;
        }
        bos.write(i);
      }
      String metadata=bos.toString();
      StringTokenizer stk=new StringTokenizer(metadata,";");
      while (stk.hasMoreTokens()) {
        String token=stk.nextToken();
        if (token.isEmpty()) {
          continue;
        }
        int index1=token.indexOf(":");
        if (index1 == -1) {
          continue;
        }
        try {
          offsetMap.put(Long.valueOf(token.substring(0,index1)),Long.valueOf(token.substring(index1 + 1)));
        }
 catch (        Exception e) {
          throw new IllegalArgumentException("Error in generating metadata",e);
        }
      }
      break;
    }
  }
  raf.seek(pos);
}

private void storeMetadata ( ) throws IOException { long pos = 0 ; int position = 0 ; int bytesToRead = readSize ; if ( raf . getLen ( ) < readSize ) { position = 0 ; bytesToRead = ( int ) raf . getLen ( ) ; } else { position = ( int ) ( raf . getLen ( ) - readSize ) ; } while ( true ) { raf . seek ( position ) ; byte [ ] bytes = new byte [ bytesToRead ] ; int lastIndex = 0 ; int totalLen = 0 ; while ( true ) { int len = raf . read ( bytes , lastIndex , bytesToRead - lastIndex ) ; totalLen += len ; if ( totalLen != bytesToRead ) { lastIndex = totalLen ; } else { break ; } } int headerIndex = lastIndexOf ( bytes , headerbytes , 0 , bytesToRead - 1 ) ; if ( headerIndex == - 1 ) { if ( position == 0 ) { raf . seek ( 0 ) ; break ; } bytesToRead = position ; if ( bytesToRead > readSize ) { bytesToRead = readSize ; } position -= ( readSize - headerbytes . length ) ; if ( position < 0 ) { position = 0 ; } } else { raf . seek ( position + headerIndex + headerbytes . length ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; while ( true ) { int i = raf . read ( ) ; if ( i == 0 ) { break ; } bos . write ( i ) ; } String metadata = bos . toString ( ) ; StringTokenizer stk = new StringTokenizer ( metadata , ";" ) ; while ( stk . hasMoreTokens ( ) ) { String token = stk . nextToken ( ) ; if ( token . isEmpty ( ) ) { continue ; } int index1 = token . indexOf ( ":" ) ; if ( index1 == - 1 ) { continue ; } try { offsetMap . put ( Long . valueOf ( token . substring ( 0 , index1 ) ) , Long . valueOf ( token . substring ( index1 + 1 ) ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Error in generating metadata" , e ) ; } } break ; } } raf . seek ( pos ) ; }
writes metadata information into map .
