private void positionAtCentralDirectory() throws IOException {
  boolean found=false;
  long off=archive.length() - MIN_EOCD_SIZE;
  if (off >= 0) {
    archive.seek(off);
    byte[] sig=JBZipOutputStream.EOCD_SIG;
    int curr=archive.read();
    while (curr != -1) {
      if (curr == sig[POS_0]) {
        curr=archive.read();
        if (curr == sig[POS_1]) {
          curr=archive.read();
          if (curr == sig[POS_2]) {
            curr=archive.read();
            if (curr == sig[POS_3]) {
              found=true;
              break;
            }
          }
        }
      }
      archive.seek(--off);
      curr=archive.read();
    }
  }
  if (!found) {
    throw new ZipException("archive is not a ZIP archive");
  }
  archive.seek(off + CFD_LOCATOR_OFFSET);
  byte[] cfdOffset=new byte[WORD];
  archive.readFully(cfdOffset);
  currentcfdfoffset=ZipLong.getValue(cfdOffset);
  archive.seek(currentcfdfoffset);
}

private void positionAtCentralDirectory ( ) throws IOException { boolean found = false ; long off = archive . length ( ) - MIN_EOCD_SIZE ; if ( off >= 0 ) { archive . seek ( off ) ; byte [ ] sig = JBZipOutputStream . EOCD_SIG ; int curr = archive . read ( ) ; while ( curr != - 1 ) { if ( curr == sig [ POS_0 ] ) { curr = archive . read ( ) ; if ( curr == sig [ POS_1 ] ) { curr = archive . read ( ) ; if ( curr == sig [ POS_2 ] ) { curr = archive . read ( ) ; if ( curr == sig [ POS_3 ] ) { found = true ; break ; } } } } archive . seek ( -- off ) ; curr = archive . read ( ) ; } } if ( ! found ) { throw new ZipException ( "archive is not a ZIP archive" ) ; } archive . seek ( off + CFD_LOCATOR_OFFSET ) ; byte [ ] cfdOffset = new byte [ WORD ] ; archive . readFully ( cfdOffset ) ; currentcfdfoffset = ZipLong . getValue ( cfdOffset ) ; archive . seek ( currentcfdfoffset ) ; }
searches for the & quot ; end of central dir record & quot ; , parses it and positions the stream at the first central directory record .
