javascript
java读取dbf数据类型,读取foxpro格式的dbf文件-JSP教程,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
總結
以上是生活随笔為你收集整理的java读取dbf数据类型,读取foxpro格式的dbf文件-JSP教程,Java技巧及代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 5G新空口关键技术之--信道编码
- 下一篇: Mybatis-Spring源码分析(五