jwo.utils.dbase
Class DbaseFileWriter

java.lang.Object
  extended by jwo.utils.dbase.DbaseFileWriter

public class DbaseFileWriter
extends Object

Used to write Dbase III files. This code is based on the class provided as part of the Geotools OpenSource mapping toolkit - http://www.geotools.org/ under the GNU Lesser General Public License. The general use of this class is:

 DbaseFileHeader header = ...
 WritableFileChannel out = new FileOutputStream("thefile.dbf").getChannel();
 DbaseFileWriter w = new DbaseFileWriter(header,out);
 while ( moreRecords ) 
 {
   w.write( getMyRecord() );
 }
 w.close();
 
You must supply the moreRecords and getMyRecord() logic.

Version:
2.3, 11th April 2006.
Author:
Ian Schneider with minor modifications by Jo Wood.

Nested Class Summary
static class DbaseFileWriter.FieldFormatter
          Utility for formatting Dbase fields.
 
Constructor Summary
DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out)
          Creates a DbaseFileWriter using the specified header and writing to the given channel.
 
Method Summary
 void close()
          Release resources associated with this writer.
 void write(Object[] record)
          Write a single dBase record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbaseFileWriter

public DbaseFileWriter(DbaseFileHeader header,
                       WritableByteChannel out)
                throws IOException
Creates a DbaseFileWriter using the specified header and writing to the given channel.

Parameters:
header - The DbaseFileHeader to write.
out - The channel to write to.
Throws:
IOException - If errors occur while initializing.
Method Detail

write

public void write(Object[] record)
           throws IOException
Write a single dBase record.

Parameters:
record - The entries to write.
Throws:
IOException - If IO error occurs or the entry doesn't comply with the header.

close

public void close()
           throws IOException
Release resources associated with this writer. Highly recommended

Throws:
IOException - If problem releasing all resources.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009