@ SuppressWarnings ( "checkstyle:magicnumber" ) public void readDBFHeader ( ) throws IOException { if ( this . finished ) { throw new EOFDBaseFileException ( ) ; } if ( this . fieldCount != - 1 ) { // The header was already red return ; } //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 0 1 byte DBF Format id // 0x03: FoxBase+, FoxPro, dBASEIII+ // dBASEIV, no memo // 0x83: FoxBase+, dBASEIII+ with memo // 0xF5: FoxPro with memo // 0x8B: dBASEIV with memo // 0x8E: dBASEIV with SQL table this . fileVersion = this . stream . readByte ( ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 1-3 3 bytes Date of last update: YMD final Calendar cal = new GregorianCalendar ( ) ; cal . set ( Calendar . YEAR , this . stream . readByte ( ) + 1900 ) ; cal . set ( Calendar . MONTH , this . stream . readByte ( ) - 1 ) ; cal . set ( Calendar . DAY_OF_MONTH , this . stream . readByte ( ) ) ; this . lastUpdateDate = cal . getTime ( ) ; // Get the count of records // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 4-7 4 bytes Number of records in the table this . recordCount = this . stream . readLEInt ( ) ; // Get the count of fields (nbBytes / size of a Field - ending byte ODh) // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 8-9 2 bytes Number of bytes in the header // #bytes = 32 + 32 * #fields + 1; this . fieldCount = ( this . stream . readLEShort ( ) - 1 ) / 32 - 1 ; // Skip the ending chars of the header // //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 10-11 2 bytes Number of bytes in the record this . recordSize = this . stream . readLEShort ( ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 12-13 2 bytes Reserved // 14 1 byte Incomplete transaction // 0x00: Ignored / Transaction End // 0x01: Transaction started // 15 1 byte Encryption flag // 0x00: Not encrypted // 0x01: Encrypted // 16-19 4 bytes Free record thread (reserved for LAN only) // 20-27 8 bytes Reserved for multi-user dBASE (dBASE III+) // 28 1 byte MDX flag (dBASE IV) // 0x00: index upon demand // 0x01: production index exists this . stream . skipBytes ( 17 ) ; // use skipBytes because it force to skip the specified amount, instead of skip() //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 29 1 byte Language driver ID // See {@link DBaseCodePage} for details. final byte b = this . stream . readByte ( ) ; this . codePage = DBaseCodePage . fromLanguageCode ( b ) ; //----------------------------------------------------------- // Bytes Size Content //----------------------------------------------------------- // 30-31 2 bytes Reserved this . stream . skipBytes ( 2 ) ; // use skipBytes because it force to skip the specified amount, instead of skip() // Update the offset of the first record with the size of the header this . firstRecordOffset = 32 ; }
Read the header of the DBF file .