コード例 #1
0
ファイル: DBFFileIO.java プロジェクト: ameltzer/mapapplet
  /**
   * This method saves the tableToSave argument to the file location. Note that we are only writing
   * C and N data types.
   *
   * @param tableToSave DBFTable data to save to the file.
   * @param file File location to save the table.
   * @throws IOException Thrown when writing fails. A reason for this might be the file is already
   *     being used by another program.
   */
  public void saveDBF(DBFTable tableToSave, File file) throws IOException {
    // WE ARE GOING TO WRITE RAW BYTE DATA
    FileOutputStream fos = new FileOutputStream(file);
    DataOutputStream dos = new DataOutputStream(fos);

    // SAVE THE FIRST 32 BYTES OF THE HEADER
    saveHeader(dos, tableToSave);

    // SUBRECORDS (32-(positionOfFirstDataRecorded-3))
    saveFields(dos, tableToSave);

    // HEADER RECORD TERMINATOR (SHOULD BE 0x0D)
    dos.writeByte(tableToSave.getTerminator());

    // AND NOW SAVE THE ACTUAL DATA
    saveRecords(dos, tableToSave);
  }