Finally finish the DBF file read and write Java source code, welcome to use
Modify the following code
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); }&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSp; 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; }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.