程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> 讀取foxpro格式的dbf文件

讀取foxpro格式的dbf文件

編輯:關於JAVA

終於整理完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; }

dbf文件定義格式:http://www.clicketyclick.dk/databases/xbase/format/dbf.Html


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved