java怎么在已有的dbf文件中追加数据,不是覆盖文件;没有报错但是打开文件后却没有追加的数据,求那位大神解答疑惑

OSC_iqZfaC 发布于 10/09 18:23
阅读 115
收藏 0

【华为云1024程序员节·向云而生】预约直播 抽14件华为电子产品礼包!>>>

public static void copyDBF(File source, File dest) {

InputStream in = null;

OutputStream out = null;

try {

in = new FileInputStream(source);

out = new FileOutputStream(dest);

byte[] buf = new byte[1024];

int bytesRead;

while ((bytesRead = in.read(buf)) > 0) {

out.write(buf, 0, bytesRead);

}

} catch(Exception e){

e.printStackTrace();

}finally {

try {

in.close();

out.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

public static void writeDBF(File dest) {

DBFWriter writer;

try {

writer = new DBFWriter(dest);

Object[] rowData = new Object[8];

rowData[0] = "1";

rowData[1] = "1";

rowData[2] = null;

rowData[3] = null;

rowData[4] = null;

rowData[5] = null;

rowData[6] = null;

rowData[7] = null;

writer.addRecord(rowData);

OutputStream fos = new FileOutputStream(dest);

writer.write(fos);

} catch (Exception e) {

e.printStackTrace();

}

}

public static void main(String[] args) {

File source = new File("D:/java/ZJRMYEK.DBF");

File dest = new File("D:/java/aaa.DBF");

writeDBF.copyDBF(source,dest);

writeDBF.writeDBF(dest);

}

加载中
0
yong9981
yong9981

dbf通常是数据库文件,要找个jdbc驱动,再用Mybatis之类的dao工具存取

0
zhaojunli
zhaojunli
这种文件没办法直接弄吧,里面都是二进制文件,又不是文本!网上以前有个收费的软件,封装oracle内部使用的工具,可以读dbf,不过要收费
返回顶部
顶部