欢迎来到天天文库
浏览记录
ID:6037117
大小:104.50 KB
页数:20页
时间:2017-12-31
《使用java实现对dbf文件的简单读写》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、使用Java实现对dbf文件的简单读写将dbf文件的读写基本分成四个类,Writer,Reader,Field,Exception,内容如下,如果需要其Doc文档和完整源码包,请发mail至iihero@eyou.com/***
Title:java访问DBF文件的接口
Description:这个类用于表示DBF文件中的写操作
Copyright:Copyright(c)2004
Company:ict
2、a.io.*;importjava.util.Calendar;//Referencedclassesofpackagecom.hexiong.jdbf://JDBFException,JDBFieldpublicclassDBFWriter{publicDBFWriter(Strings,JDBFieldajdbfield[])throwsJDBFException{stream=null;recCount=0;fields=null;fileName=null;dbfEncoding=null;fileName=s;try{init(newFileOutputStream(s)
3、,ajdbfield);}catch(FileNotFoundExceptionfilenotfoundexception){thrownewJDBFException(filenotfoundexception);}}publicDBFWriter(OutputStreamoutputstream,JDBFieldajdbfield[])throwsJDBFException{stream=null;recCount=0;fields=null;fileName=null;dbfEncoding=null;init(outputstream,ajdbfield);}publicD
4、BFWriter(Strings,JDBFieldajdbfield[],Strings1)throwsJDBFException{stream=null;recCount=0;fields=null;fileName=null;dbfEncoding=null;fileName=s;try{dbfEncoding=s1;init(newFileOutputStream(s),ajdbfield);}catch(FileNotFoundExceptionfilenotfoundexception){thrownewJDBFException(filenotfoundexceptio
5、n);}}privatevoidinit(OutputStreamoutputstream,JDBFieldajdbfield[])throwsJDBFException{fields=ajdbfield;try{stream=newBufferedOutputStream(outputstream);writeHeader();for(inti=0;i6、wnewJDBFException(exception);}}privatevoidwriteHeader()throwsIOException{byteabyte0[]=newbyte[16];abyte0[0]=3;Calendarcalendar=Calendar.getInstance();abyte0[1]=(byte)(calendar.get(1)-1900);abyte0[2]=(byte)calendar.get(2);abyte0[3]=(byte)calendar.get(5);abyte0[4]=0;abyte0[5]=0;abyte0[6]=0;abyte7、0[7]=0;inti=(fields.length+1)*32+1;abyte0[8]=(byte)(i%256);abyte0[9]=(byte)(i/256);intj=1;for(intk=0;k
6、wnewJDBFException(exception);}}privatevoidwriteHeader()throwsIOException{byteabyte0[]=newbyte[16];abyte0[0]=3;Calendarcalendar=Calendar.getInstance();abyte0[1]=(byte)(calendar.get(1)-1900);abyte0[2]=(byte)calendar.get(2);abyte0[3]=(byte)calendar.get(5);abyte0[4]=0;abyte0[5]=0;abyte0[6]=0;abyte
7、0[7]=0;inti=(fields.length+1)*32+1;abyte0[8]=(byte)(i%256);abyte0[9]=(byte)(i/256);intj=1;for(intk=0;k
此文档下载收益归作者所有