Package org.geotools.data.shapefile.dbf
Class DbaseFileWriter
- Object
-
- DbaseFileWriter
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DbaseFileWriter extends Object implements Closeable
A DbaseFileWriter is used to write a dbase III format file. The general use of this class is:You must supply theDbaseFileHeader header = ... WritableFileChannel out = new FileOutputStream("thefile.dbf").getChannel(); DbaseFileWriter w = new DbaseFileWriter(header,out); while ( moreRecords ) { w.write( getMyRecord() ); } w.close();moreRecordsandgetMyRecord()logic...- Author:
- Ian Schneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDbaseFileWriter.FieldFormatterUtility for formatting Dbase fields.
-
Constructor Summary
Constructors Constructor Description DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out)Create a DbaseFileWriter using the specified header and writing to the given channel.DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out, Charset charset)Create a DbaseFileWriter using the specified header and writing to the given channel.DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out, Charset charset, TimeZone timeZone)Create a DbaseFileWriter using the specified header and writing to the given channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Release resources associated with this writer.DbaseFileHeadergetHeader()booleangetReportFieldSizeErrors()voidsetReportFieldSizeErrors(boolean reportFieldSizeErrors)voidwrite(Object[] record)Write a single dbase record.
-
-
-
Constructor Detail
-
DbaseFileWriter
public DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out) throws IOException
Create 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.
-
DbaseFileWriter
public DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out, Charset charset) throws IOException
Create 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.
-
DbaseFileWriter
public DbaseFileWriter(DbaseFileHeader header, WritableByteChannel out, Charset charset, TimeZone timeZone) throws IOException
Create a DbaseFileWriter using the specified header and writing to the given channel.- Parameters:
header- The DbaseFileHeader to write.out- The Channel to write to.charset- The charset the dbf is (will be) encoded in- Throws:
IOException- If errors occur while initializing.
-
-
Method Detail
-
write
public void write(Object[] record) throws IOException, DbaseFileException
Write a single dbase record.- Parameters:
record- The entries to write.- Throws:
IOException- If IO error occurs.DbaseFileException- If the entry doesn't comply to the header.
-
close
public void close() throws IOExceptionRelease resources associated with this writer. Highly recommended- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If errors occur.
-
getReportFieldSizeErrors
public boolean getReportFieldSizeErrors()
-
setReportFieldSizeErrors
public void setReportFieldSizeErrors(boolean reportFieldSizeErrors)
-
getHeader
public DbaseFileHeader getHeader()
-
-