67,513
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
String msg = "";
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
//Pattern p = Pattern.compile("^L\\d+\\.dbf$",
Pattern p = Pattern.compile("L090203.dbf",
Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(name);
return m.matches();
}
};
String yaSuoPath = "D:\\workspace\\linc\\WebContent\\upload\\2012718\\";
File dir = new File(yaSuoPath);
String[] tables = dir.list(filter);
for (String table : tables) {
try {
DBFReader dBFReader = new DBFReader(new FileInputStream(new File(yaSuoPath+table)));
dBFReader.setCharactersetName("GBK");
Object[] fieldValues = null;
int count = dBFReader.getRecordCount();
while((fieldValues=dBFReader.nextRecord())!= null&&!(count--<=0)){
for(int i=0;i<fieldValues.length;i++){
Object value = fieldValues[i];
if(value==null){
System.out.println("空");
}else{
System.out.println(fieldValues[i].toString());
}
}
}
} catch (Exception e) {
msg = "导入发生错误。";
e.printStackTrace();
}
}
}