欢迎光临
我们一直在努力

读取foxpro格式的dbf文件-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

原文出处

终于整理完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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 读取foxpro格式的dbf文件-JSP教程,Java技巧及代码
分享到: 更多 (0)

相关推荐

  • 暂无文章