Class DBaseFileWriter

  • All Implemented Interfaces:
    AutoCloseable

    public class DBaseFileWriter
    extends Object
    implements AutoCloseable
    This class permits to write a dBase file.

    This class supports dBASE version 5. Version 7 specification is available at http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm.

    ESRi Limitations

    Additionnally, this writer includes the ESRi restrictions on dBASE files. Shapefile feature attributes are stored in an associated .dbf file, and so attributes suffer a number of limitations.

    Attribute names can only be up to 10 characters long. Longer names will be silently truncated. This may result in non-unique column names, which will definitely cause problems later. Starting with version 1.7, the OGR Shapefile driver tries to generate unique field names. Successive duplicate field names, including those created by truncation to 10 characters, will be truncated to 8 characters and appended with a serial number from 1 to 99.

    Only Integer, Real, String and Date (not DateTime, just year/month/day) field types are supported. The various list, and binary field types cannot be created.

    The field width and precision are directly used to establish storage size in the .dbf file. This means that strings longer than the field width, or numbers that don't fit into the indicated field format will suffer truncation.

    Integer fields without an explicit width are treated as width 11.

    Real (floating point) fields without an explicit width are treated as width 24 with 15 decimal places of precision.

    String fields without an assigned width are treated as 80 characters.

    Also, .dbf files are required to have at least one field. If none are created by the application an "FID" field will be automatically created and populated with the record number.

    The OGR shapefile driver supports rewriting existing shapes in a shapefile as well as deleting shapes. Deleted shapes are marked for deletion in the .dbf file, and then ignored by OGR. To actually remove them permanently (resulting in renumbering of FIDs) invoke the SQL 'REPACK <tablename>' via the datasource ExecuteSQL() method.

    Since:
    14.0
    Version:
    17.0 2020-01-04 14:41:52
    Author:
    Stéphane GALLAND, Olivier LAMOTTE
    Maven Group Id:
    org.arakhne.afc.advanced
    Maven Artifact Id:
    dbasefile
    • Constructor Detail

      • DBaseFileWriter

        public DBaseFileWriter​(File stream)
                        throws IOException
        Constructor.
        Parameters:
        stream - is the file to write.
        Throws:
        IOException - in case of error.
      • DBaseFileWriter

        public DBaseFileWriter​(URL stream)
                        throws IOException
        Constructor.
        Parameters:
        stream - is the file to write.
        Throws:
        IOException - in case of error.
      • DBaseFileWriter

        public DBaseFileWriter​(WritableByteChannel channel)
        Constructor.
        Parameters:
        channel - is the channel to write in.
      • DBaseFileWriter

        public DBaseFileWriter​(OutputStream dbfStream)
        Constructor.
        Parameters:
        dbfStream - is the output stream to use