private int loadHeader() {
    if (headerLoaded) return 0;
    InputStream s = stream;
    if (s == null) return -1;
    try {
      BufferedInputStream bs = new BufferedInputStream(s);
      ds = new DataInputStream(bs);
      /* read the header as one block of bytes*/
      Header = new byte[32];
      ds.readFully(Header);
      //System.out.println("dbase header is " + Header);
      if (Header[0] == '<') { //looks like html coming back to us!
        close(ds);
        return -1;
      }
      filetype = Header[0];
      /* 4 bytes for number of records is in little endian */
      nrecords = Swap.swapInt(Header, 4);
      nbytesheader = Swap.swapShort(Header, 8);

      /* read in the Field Descriptors */
      /* have to figure how many there are from
      * the header size.  Should be nbytesheader/32 -1
      */
      nfields = (nbytesheader / 32) - 1;
      if (nfields < 1) {
        System.out.println("nfields = " + nfields);
        System.out.println("nbytesheader = " +
                nbytesheader);
        return -1;
      }
      FieldDesc = new DbaseFieldDesc[nfields];
      data = new DbaseData[nfields];
      for (int i = 0; i < nfields; i++) {
        FieldDesc[i] = new DbaseFieldDesc(ds, filetype);
        data[i] = new DbaseData(FieldDesc[i],
                nrecords);
      }

      /* read the last byte of the header (0x0d) */
      ds.readByte();

      headerLoaded = true;
    } catch (java.io.IOException e) {
      close(s);
      return -1;
    }
    return 0;
  }
private int loadHeader() {
    if (headerLoaded) return 0;
    InputStream s = stream;
    if (s == null) return -1;
    try {
      BufferedInputStream bs = new BufferedInputStream(s);
      ds = new DataInputStream(bs);
      
      Header = new byte[32];
      ds.readFully(Header);
      
      if (Header[0] == '<') { 
        close(ds);
        return -1;
      }
      filetype = Header[0];
      
      nrecords = Swap.swapInt(Header, 4);
      nbytesheader = Swap.swapShort(Header, 8);

      
      
      nfields = (nbytesheader / 32) - 1;
      if (nfields < 1) {
        System.out.println("nfields = " + nfields);
        System.out.println("nbytesheader = " +
                nbytesheader);
        return -1;
      }
      FieldDesc = new DbaseFieldDesc[nfields];
      data = new DbaseData[nfields];
      for (int i = 0; i < nfields; i++) {
        FieldDesc[i] = new DbaseFieldDesc(ds, filetype);
        data[i] = new DbaseData(FieldDesc[i],
                nrecords);
      }

      
      ds.readByte();

      headerLoaded = true;
    } catch (java.io.IOException e) {
      close(s);
      return -1;
    }
    return 0;
  }
private int loadHeader ( ) { if ( headerLoaded ) return 0 ; InputStream s = stream ; if ( s == null ) return - 1 ; try { BufferedInputStream bs = new BufferedInputStream ( s ) ; ds = new DataInputStream ( bs ) ; /* read the header as one block of bytes*/ Header = new byte [ 32 ] ; ds . readFully ( Header ) ; //System.out.println("dbase header is " + Header);
 if ( Header [ 0 ] == ' ' ) { //looks like html coming back to us!
 close ( ds ) ; return - 1 ; } filetype = Header [ 0 ] ; /* 4 bytes for number of records is in little endian */ nrecords = Swap . swapInt ( Header , 4 ) ; nbytesheader = Swap . swapShort ( Header , 8 ) ; /* read in the Field Descriptors */ /* have to figure how many there are from
      * the header size.  Should be nbytesheader/32 -1
      */ nfields = ( nbytesheader / 32 ) - 1 ; if ( nfields < 1 ) { System . out . println ( "nfields = " + nfields ) ; System . out . println ( "nbytesheader = " + nbytesheader ) ; return - 1 ; } FieldDesc = new DbaseFieldDesc [ nfields ] ; data = new DbaseData [ nfields ] ; for ( int i = 0 ; i < nfields ; i ++ ) { FieldDesc [ i ] = new DbaseFieldDesc ( ds , filetype ) ; data [ i ] = new DbaseData ( FieldDesc [ i ] , nrecords ) ; } /* read the last byte of the header (0x0d) */ ds . readByte ( ) ; headerLoaded = true ; } catch ( java . io . IOException e ) { close ( s ) ; return - 1 ; } return 0 ; }
Load the dbase file header.

@return 0 for success, -1 for failure
Load the dbase file header .