public class DBFReader extends DBFBase implements Closeable
This Class is used to read data from a DBF file. Meta data and records can be queried against this document.
DBFReader cannot write to a DBF file. For creating DBF files use DBFWriter.
Fetching records is possible only in the forward direction and cannot be re-wound. In such situations, a suggested approach is to reconstruct the object.
The nextRecord() method returns an array of Objects and the types of these Object are as follows:
| xBase Type | Java Type |
|---|---|
| C | String |
| N | java.math.BigDecimal |
| F | java.math.BigDecimal |
| L | Boolean |
| D | java.util.Date |
| Y | java.math.BigDecimal |
| I | Integer |
| T | java.util.Date |
| @ | java.util.Date |
| Integer | |
| V | String |
| O | Double |
| M | java.lang.String or byte[] |
| B | byte[] or java.lang.Double |
| G | byte[] |
| P | byte[] |
| Q | byte[] |
| Modifier and Type | Field and Description |
|---|---|
protected DataInputStream |
dataInputStream |
protected InputStream |
inputStream |
DEFAULT_CHARSET, END_OF_DATA| Constructor and Description |
|---|
DBFReader(InputStream in)
Intializes a DBFReader object.
|
DBFReader(InputStream in,
Boolean showDeletedRows)
Intializes a DBFReader object.
|
DBFReader(InputStream in,
Charset charset)
Initializes a DBFReader object.
|
DBFReader(InputStream in,
Charset charset,
boolean showDeletedRows)
Initializes a DBFReader object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected int |
getEstimatedOutputSize() |
DBFField |
getField(int index)
Returns the asked Field.
|
int |
getFieldCount()
Returns the number of field in the DBF.
|
protected Object |
getFieldValue(DBFField field) |
protected DBFHeader |
getHeader() |
Date |
getLastModificationDate()
Returns the last time the file was modified
|
int |
getRecordCount()
Returns the number of records in the DBF.
|
boolean |
isTrimRightSpaces()
Determine if character fields should be right trimmed (default true)
|
Object[] |
nextRecord()
Reads the returns the next row in the DBF stream.
|
DBFRow |
nextRow()
Reads the returns the next row in the DBF stream.
|
void |
setMemoFile(File memoFile)
Sets the memo file (DBT or FPT) where memo fields will be readed.
|
void |
setTrimRightSpaces(boolean trimRightSpaces)
Determine if character fields should be right trimmed (default true)
|
protected void |
skip(int bytesToSkip)
Safely skip bytesToSkip bytes (in some bufferd scenarios skip doesn't really skip all requested bytes)
|
String |
toString() |
getCharactersetName, getCharset, setCharactersetName, setCharsetprotected InputStream inputStream
protected DataInputStream dataInputStream
public DBFReader(InputStream in)
in - the InputStream where the data is read from.public DBFReader(InputStream in, Boolean showDeletedRows)
in - the InputStream where the data is read from.showDeletedRows - can be used to identify records that have been deleted.public DBFReader(InputStream in, Charset charset)
in - the InputStream where the data is read from.charset - charset used to decode field names and field contents. If null, then is autedetected from dbf filepublic DBFReader(InputStream in, Charset charset, boolean showDeletedRows)
in - the InputStream where the data is read from.charset - charset used to decode field names and field contents. If null, then is autedetected from dbf fileshowDeletedRows - can be used to identify records that have been deleted.public int getRecordCount()
public Date getLastModificationDate()
public DBFField getField(int index)
index - Index of the field. Index of the first field is zero.public int getFieldCount()
public Object[] nextRecord()
public DBFRow nextRow()
protected Object getFieldValue(DBFField field) throws IOException
IOExceptionprotected void skip(int bytesToSkip)
throws IOException
bytesToSkip - number of bytes to skipIOException - if some IO error happensprotected DBFHeader getHeader()
public boolean isTrimRightSpaces()
public void setTrimRightSpaces(boolean trimRightSpaces)
trimRightSpaces - if reading fields should trim right spacespublic void setMemoFile(File memoFile)
memoFile - the file containing the memo datapublic void close()
close in interface Closeableclose in interface AutoCloseableprotected int getEstimatedOutputSize()
Copyright © 2018. All rights reserved.