首页 > 数据库技术 > 详细

读取foxpro格式的dbf文件

时间:2014-11-15 02:01:49      阅读:170      评论:0      收藏:0      [点我收藏+]

原文出处

终于整理完dbf文件读写的java源码,欢迎使用

修改以下代码

private void init(InputStream inputstream) throws JDBFException { try { stream = new DataInputStream(inputstream); int i = readHeader(); fields = new JDBField[i]; int j = 1; for(int k = 0; k < i; k++) { fields[k] = readFieldHeader(); j += fields[k].getLength(); }

if(stream.read() < 1) throw new JDBFException("Unexpected end of file reached."); nextRecord = new byte[j]; try { //stream.readFully(nextRecord); stream.read(new byte[263]); stream.readFully(nextRecord); } catch(EOFException eofexception) { nextRecord = null; stream.close(); } } catch(IOException ioexception) { throw new JDBFException(ioexception); } }

private int readHeader() throws IOException, JDBFException { byte abyte0[] = new byte[16]; try { stream.readFully(abyte0); } catch(EOFException eofexception) { throw new JDBFException("Unexpected end of file reached."); } int i = abyte0[8]; if(i < 0) i += 256; i += 256 * abyte0[9]; i -= 264; i = --i / 32; //i = --i / 32; //i--; try { stream.readFully(abyte0); } catch(EOFException eofexception1) { throw new JDBFException("Unexpected end of file reached."); } return i; }

读取foxpro格式的dbf文件

原文:http://www.blogjava.net/seoyouhua/archive/2014/11/14/420086.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!