maven配置
<!-- https://mvnrepository.com/artifact/com.linuxense/javadbf -->
<dependency>
<groupId>com.linuxense</groupId>
<artifactId>javadbf</artifactId>
<version>0.4.0</version>
</dependency>
代码片段
public static void main(String[] args) {
Text01.readDBF("D:/test.dbf");
/*Text01.writeDBF("D:/test.dbf");*/
}
/**
* 读取dbf
*
* @param path
*/
public static void readDBF(String path) {
InputStream fis = null;
try {
// 读取文件的输入流
fis = new FileInputStream(path);
// 根据输入流初始化一个DBFReader实例,用来读取DBF文件信息
DBFReader reader = new DBFReader(fis);
// 解决乱码
reader.setCharactersetName("GBK");
// 调用DBFReader对实例方法得到path文件中字段的个数
int fieldsCount = reader.getFieldCount();
// 取出字段信息
for (int i = 0; i < fieldsCount; i++) {
DBFField field = reader.getField(i