com.svcon.jdbf
Class DBFWriter

java.lang.Object
  |
  +--com.svcon.jdbf.DBFWriter

public class DBFWriter
extends java.lang.Object

Used to write database (DBF) files.

Create a DBFWriter passing a file name and a list of fields, then add the records one by one, and close it. Make sure you always close your DBF files, even if there is an error writing some of the records.


Constructor Summary
DBFWriter(java.io.OutputStream os, JDBField[] fields)
          Opens an output stream for writing.
DBFWriter(java.lang.String fileName, JDBField[] fields)
          Opens a DBF file for writing.
DBFWriter(java.lang.String fileName, JDBField[] fields, java.lang.String dbfEncoding)
          Opens a DBF file for writing, bytes in DBF will be converted from UNICODE to national charset.
 
Method Summary
 void addRecord(java.lang.Object[] values)
          Writes a record to the DBF file.
 void close()
          Closes the DBF file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBFWriter

public DBFWriter(java.lang.String fileName,
                 JDBField[] fields)
          throws JDBFException
Opens a DBF file for writing.
Parameters:
fileName - the name of the file.
fields - an array of database fields.
Throws:
JDBFException - if an error occurred opening the file for writing.

DBFWriter

public DBFWriter(java.io.OutputStream os,
                 JDBField[] fields)
          throws JDBFException
Opens an output stream for writing. A DBF structure will be written to the stream.
Parameters:
os - the output stream.
fields - an array of database fields.
Throws:
JDBFException - if an error occurred opening the stream for writing.

DBFWriter

public DBFWriter(java.lang.String fileName,
                 JDBField[] fields,
                 java.lang.String dbfEncoding)
          throws JDBFException
Opens a DBF file for writing, bytes in DBF will be converted from UNICODE to national charset.
Parameters:
fileName - the name of the file.
fields - an array of database fields.
dbfEncoding - an array of database fields.
Throws:
JDBFException - if an error occurred opening the file for writing.
Method Detail

addRecord

public void addRecord(java.lang.Object[] values)
               throws JDBFException
Writes a record to the DBF file.
Parameters:
values - an array of values that represent the new record.
Throws:
JDBFException - if an error occurred writing the record.

close

public void close()
           throws JDBFException
Closes the DBF file.
Throws:
JDBFException - if an error occurred closing the file.