public class DbaseFileReader extends Object
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in ) Object[] fields = new
Object[r.getHeader().getNumFields()]; while (r.hasNext()) {
r.readEntry(fields); // do stuff } r.close();
For consumers who wish to be a bit more selective with their
reading of rows, the Row object has been added. The semantics are the same as
using the readEntry method, but remember that the Row object is always the
same. The values are parsed as they are read, so it pays to copy them out (as
each call to Row.read() will result in an expensive String parse).
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in ) int fields =
r.getHeader().getNumFields(); while (r.hasNext()) { DbaseFileReader.Row row =
r.readRow(); for (int i = 0; i < fields; i++) { // do stuff Foo.bar(
row.read(i) ); } } r.close();
| Constructor and Description |
|---|
DbaseFileReader(FileChannel channel,
String forceEncoding)
Creates a new instance of DBaseFileReader
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Clean up all resources associated with this reader.
|
int |
getFieldCount() |
Object |
getFieldValue(int row,
int column) |
DbaseFileHeader |
getHeader()
Get the header from this file.
|
int |
getRecordCount() |
public DbaseFileReader(FileChannel channel, String forceEncoding) throws IOException
channel - The readable channel to use.IOException - If an error occurs while initializing.public DbaseFileHeader getHeader()
public void close()
throws IOException
IOException - If an error occurs.public Object getFieldValue(int row, int column) throws IOException
IOExceptionpublic int getRecordCount()
public int getFieldCount()
Copyright © 2019 CNRS. All rights reserved.