- 浏览: 92554 次
- 性别:
- 来自: 北京
最新评论
-
xiangzihehao:
非常感谢~
JFreechart V1.0.9 Guide(英文版) -
minn84:
...
一个老程序员的忠告:不要一辈子靠技术生存 -
小斌江:
非常非常非常的感谢楼主。。。
JFreechart V1.0.9 Guide(英文版) -
yutian8888:
谢谢你老兄!我找了很久,在你这里得到的解决!!
Java web 根据url下载文件IE出错,FF正常 -
liuwenbo200285:
学习了,面试的时候经常问这个问题,估计有的面试官也不知道如果不 ...
StringBuilder StringBuffer and "+"
先来定义dbf文件的格式,先来定义dbfheader,
里面暗含有一个类DbaseField
下面是DBFFileReader,用FileChannel来读取,这里用channel读取时一般时把文件整个的读进来放到内存中,然后再去处理,如果这里你有别的好的方法,不用直接读取到内存中,请在下面跟贴,谢谢赐教.
读取就用下面的代码来读,相应的exception和相关的引入类,自行引入,
要导入的包在下面
import java.io.EOFException; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.ReadableByteChannel; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; /** * DBFFileHeader Define. * */ public class DBFFileHeader { /** MAXFILELENGTH. */ private static final int MAXFILELENGTH = 256; /** RESERVEDBYTE2. */ private static final int RESERVEDBYTE2 = 14; /** MAXFIELDNAMELENGTH. */ private static final int MAXFIELDNAMELENGTH = 11; /** HEADRESERVEDBYTE. */ private static final int HEADRESERVEDBYTE = 20; /** FFMASK. */ private static final int FFMASK = 0xff; /** bits of one byte . */ private static final int BYTELENGTH = 8; /** length of bytes read from file for detected basic elements. */ private static final int LEADOFFILE = 10; /** YEARCOMPARE dbf file time field limited to <99. */ private static final int YEARCOMPARE = 90; /** YEAR2000. */ private static final int YEAR2000 = 2000; /** YEAR1900. */ private static final int YEAR1900 = 1900; /** CHUNKSIZE use while readdatas. */ private static final int CHUNKSIZE = 1024; /** Constant for the size of a record. */ private static final int FILE_DESCRIPTOR_SIZE = 32; /** type of the file, must be 03h. */ private static final byte MAGIC = 0x03; /** Date the file was last updated. */ private Date date = new Date(); /** recordCnt. */ private int recordCnt = 0; /** fieldCnt. */ private int fieldCnt = 0; /** * set this to a default length of 1, which is enough for one "space". * character which signifies an empty record */ private int recordLength = 1; /** * set this to a flagged value so if no fields are added before the write. * we know to adjust the headerLength to MINIMUM_HEADER */ private int headerLength = -1; /** largestFieldSize. */ private int largestFieldSize = 0; /** * collection of header records. lets start out with a zero-length array, * just in case */ private DbaseField[] fields = new DbaseField[0]; /** * Method for read. * * @param buffer * @param channel * @throws IOException */ private void read(final ByteBuffer buffer, final ReadableByteChannel channel) throws IOException { if (buffer.remaining() > 0) { if (channel.read(buffer) == -1) { throw new EOFException("Premature end of file"); } } } /** * Returns the field length in bytes. * * @param inIndex * The field index. * @return The length in bytes. */ public int getFieldLength(final int inIndex) { return fields[inIndex].fieldLength; } /** * Retrieve the location of the decimal point within the field. * * @param inIndex * The field index. * @return The decimal count. */ public int getFieldDecimalCount(final int inIndex) { return fields[inIndex].getDecimalCount(); } /** * Retrieve the Name of the field at the given index. * * @param inIndex * The field index. * @return The name of the field. */ public String getFieldName(final int inIndex) { return fields[inIndex].fieldName; } /** * Get the character class of the field. Retrieve the type of field at the * given index * * @param inIndex * The field index. * @return The dbase character representing this field. */ public char getFieldType(final int inIndex) { return fields[inIndex].fieldType; } /** * Get the date this file was last updated. * * @return The Date last modified. */ public Date getLastUpdateDate() { return date; } /** * Return the number of fields in the records. * * @return The number of fields in this table. */ public int getNumFields() { return fields.length; } /** * Return the number of records in the file. * * @return The number of records in this table. */ public int getNumRecords() { return recordCnt; } /** * Get the length of the records in bytes. * * @return The number of bytes per record. */ public int getRecordLength() { return recordLength; } /** * Get the length of the header. * * @return The length of the header in bytes. */ public int getHeaderLength() { return headerLength; } /** * Read the header data from the DBF file. * * @param channel * A readable byte channel. If you have an InputStream you need * to use, you can call java.nio.Channels.getChannel(InputStream * in). * @throws IOException * If errors occur while reading. */ public void readHeader(final ReadableByteChannel channel, final boolean useDirectBuffer) throws IOException { // we'll read in chunks of 1K ByteBuffer in; if (useDirectBuffer) { in = ByteBuffer.allocateDirect(DBFFileHeader.CHUNKSIZE); } else { in = ByteBuffer.allocate(DBFFileHeader.CHUNKSIZE); } in.order(ByteOrder.LITTLE_ENDIAN); // only want to read first 10 bytes... in.limit(LEADOFFILE); // read and reset in byteBuffer read(in, channel); in.position(0); // type of file. final byte magic = in.get(); if (magic != MAGIC) { throw new IOException("Unsupported DBF file Type " + Integer.toHexString(magic)); } // parse the update date information. int tempUpdateYear = in.get(); final int tempUpdateMonth = in.get(); final int tempUpdateDay = in.get(); // correct year present if (tempUpdateYear > YEARCOMPARE) { tempUpdateYear = tempUpdateYear + YEAR1900; } else { tempUpdateYear = tempUpdateYear + YEAR2000; } final Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, tempUpdateYear); c.set(Calendar.MONTH, tempUpdateMonth - 1); c.set(Calendar.DATE, tempUpdateDay); date = c.getTime(); // read the number of records. recordCnt = in.getInt(); // read the length of the header structure. // ahhh.. unsigned little-endian shorts // mask out the byte and or it with shifted 2nd byte if (in.order().equals(ByteOrder.BIG_ENDIAN)) { headerLength = ((in.get() & FFMASK) << BYTELENGTH) | (in.get() & FFMASK); } else { headerLength = (in.get() & FFMASK) | ((in.get() & FFMASK) << BYTELENGTH); } // if the header is bigger than our 1K, reallocate if (headerLength > in.capacity()) { if (useDirectBuffer) { DirectBufferUtil.clean(in); } in = ByteBuffer.allocateDirect(headerLength - LEADOFFILE); } in.limit(headerLength - LEADOFFILE); in.position(0); read(in, channel); in.position(0); // read the length of a record // ahhh.. unsigned little-endian shorts recordLength = (in.get() & FFMASK) | ((in.get() & FFMASK) << BYTELENGTH); // skip / skip thesreserved bytes in the header. in.position(in.position() + HEADRESERVEDBYTE); // calculate the number of Fields in the header fieldCnt = (headerLength - FILE_DESCRIPTOR_SIZE - 1) / FILE_DESCRIPTOR_SIZE; // read all of the header records final List<Object> lfields = new ArrayList<Object>(); for (int i = 0; i < fieldCnt; i++) { final DbaseField field = new DbaseField(); // read the field name final byte[] buffer = new byte[MAXFIELDNAMELENGTH]; in.get(buffer); String name = new String(buffer); final int nullPoint = name.indexOf(0); if (nullPoint != -1) { name = name.substring(0, nullPoint); } field.setFieldName(name.trim()); // read the field type field.setFieldType((char) in.get()); // read the field data address, offset from the start of the record. field.setFieldDataAddress(in.getInt()); // read the field length in bytes int length = in.get(); if (length < 0) { length = length + MAXFILELENGTH; } field.setFieldLength(length); if (length > largestFieldSize) { largestFieldSize = length; } // read the field decimal count in bytes field.setDecimalCount(in.get()); // rreservedvededved bytes. // in.skipBytes(14); in.position(in.position() + RESERVEDBYTE2); // some broken shapefiles have 0-length attributes. The reference // implementation // (ArcExplorer 2.0, built with MapObjects) just ignores them. if (field.getFieldLength() > 0) { lfields.add(field); } } // Last byte is a marker for the end of the field definitions. // in.skipBytes(1); in.position(in.position() + 1); if (useDirectBuffer) { DirectBufferUtil.clean(in); } fields = new DbaseField[lfields.size()]; fields = lfields.toArray(fields); } /** * Get the largest field size of this table. * * @return The largt field size iiin bytes. */ public int getLargestFieldSize() { return largestFieldSize; } /** * Class for holding the information assicated with a record. */ class DbaseField { /** fieldName. */ private String fieldName; /** Field Type (C N L D or M). */ private char fieldType; /** Field Data Address offset from the start of the record.. */ private int fieldDataAddress; /** Length of the data in bytes. */ private int fieldLength; /** Field decimal count in Binary, indicating where the decimal is. */ private int decimalCount; /** * Set fieldName. * * @param fieldName * The fieldName to set. */ void setFieldName(final String fieldName) { this.fieldName = fieldName; } /** * Get fieldName. * * @return Returns the fieldName. */ String getFieldName() { return fieldName; } /** * Set fieldType. * * @param fieldType * The fieldType to set. */ void setFieldType(final char fieldType) { this.fieldType = fieldType; } /** * Get fieldType. * * @return Returns the fieldType. */ char getFieldType() { return fieldType; } /** * Set fieldDataAddress. * * @param fieldDataAddress * The fieldDataAddress to set. */ void setFieldDataAddress(final int fieldDataAddress) { this.fieldDataAddress = fieldDataAddress; } /** * Get fieldDataAddress. * * @return Returns the fieldDataAddress. */ int getFieldDataAddress() { return fieldDataAddress; } /** * Set fieldLength. * * @param fieldLength * The fieldLength to set. */ void setFieldLength(final int fieldLength) { this.fieldLength = fieldLength; } /** * Get fieldLength. * * @return Returns the fieldLength. */ int getFieldLength() { return fieldLength; } /** * Set decimalCount. * * @param decimalCount * The decimalCount to set. */ void setDecimalCount(final int decimalCount) { this.decimalCount = decimalCount; } /** * Get decimalCount. * * @return Returns the decimalCount. */ int getDecimalCount() { return decimalCount; } }
里面暗含有一个类DbaseField
下面是DBFFileReader,用FileChannel来读取,这里用channel读取时一般时把文件整个的读进来放到内存中,然后再去处理,如果这里你有别的好的方法,不用直接读取到内存中,请在下面跟贴,谢谢赐教.
public class DBFFileReader { /** Buffer Size. */ private static final int EKBYTESIZE = 8 * 1024; /** DBF File Header . */ private DBFFileHeader header; /** Data Input Buffer. */ private ByteBuffer buffer; /** File relative channel. */ private ReadableByteChannel channel; /** use for read datas in dbf. */ private CharBuffer charBuffer; /** decoder. */ private CharsetDecoder decoder; /** fieldTypes. */ private char[] fieldTypes; /** fieldLengths. */ private int[] fieldLengths; /** ready counts. */ private int cnt = 1; /** current read row , if not read calls this may be empty. */ private Row row; /** whether use memoryMap. */ private boolean useMemoryMappedBuffer; /** randomAccessEnabled. */ // private final boolean randomAccessEnabled; /** current dataBuffer Offset. */ private int currentOffset = 0; /** * Construct for DBFFileReader.java. * * @param channel * dbfFile channel. * @param useDirectBuffer * where use useDirectBuffer , if file is not to big to * handler use false maybe more faster . * @throws IOException */ public DBFFileReader(final ReadableByteChannel channel, final boolean useDirectBuffer) throws IOException { this.channel = channel; this.useMemoryMappedBuffer = useDirectBuffer; // this.randomAccessEnabled = (channel instanceof FileChannel); header = new DBFFileHeader(); header.readHeader(channel, useDirectBuffer); init(); } /** * Prepare buffer and charbuffer for further read. * * @throws IOException */ private void init() throws IOException { // create the ByteBuffer // if we have a FileChannel, lets map it if ((channel instanceof FileChannel) && this.useMemoryMappedBuffer) { final FileChannel fc = (FileChannel) channel; buffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); buffer.position((int) fc.position()); this.currentOffset = 0; } else { // Force useMemoryMappedBuffer to false this.useMemoryMappedBuffer = false; // Some other type of channel // start with a 8K buffer, should be more than adequate int size = EKBYTESIZE; // if for some reason its not, resize it if (header.getRecordLength() > size) { size = header.getRecordLength(); } buffer = ByteBuffer.allocate(size); // fill it and reset fill(buffer, channel); buffer.flip(); this.currentOffset = header.getHeaderLength(); } // The entire file is in little endian buffer.order(ByteOrder.LITTLE_ENDIAN); // Set up some buffers and lookups for efficiency fieldTypes = new char[header.getNumFields()]; fieldLengths = new int[header.getNumFields()]; for (int i = 0, ii = header.getNumFields(); i < ii; i++) { fieldTypes[i] = header.getFieldType(i); fieldLengths[i] = header.getFieldLength(i); } charBuffer = CharBuffer.allocate(header.getRecordLength()); final Charset chars = Charset.forName("ISO-8859-1"); // Charset chars = Charset.forName("gbk"); decoder = chars.newDecoder(); row = new Row(); } /** * Get current row data. Call this right after Row.read() is invoke; * * @return * @throws IOException */ public Row readRow() throws IOException { read(); return row; } /** * Method for read. * * @throws IOException */ private void read() throws IOException { boolean foundRecord = false; while (!foundRecord) { // if data is load in batch , we should adjust buffer bufferCheck(); charBuffer.position(0); buffer.limit(buffer.position() + header.getRecordLength()); decoder.decode(buffer, charBuffer, true); buffer.limit(buffer.capacity()); charBuffer.flip(); foundRecord = true; } cnt++; } /** * Adjust buffer and reload data if necessary. * * @throws IOException */ private void bufferCheck() throws IOException { // remaining is less than record length // compact the remaining data and read again if (!buffer.isReadOnly() && (buffer.remaining() < header.getRecordLength())) { this.currentOffset += buffer.position(); buffer.compact(); fill(buffer, channel); buffer.position(0); } } /** * fill buffer with data in channel. * * @param buffer * @param channel * @return * @throws IOException */ protected int fill(final ByteBuffer buffer, final ReadableByteChannel channel) throws IOException { int r = buffer.remaining(); // channel reads return -1 when EOF or other error // because they a non-blocking reads, 0 is a valid return value!! while ((buffer.remaining() > 0) && (r != -1)) { r = channel.read(buffer); } if (r == -1) { buffer.limit(buffer.position()); } return r; } /** * Close reader. * @throws IOException */ public void close() throws IOException { if (channel.isOpen()) { channel.close(); } if (buffer instanceof MappedByteBuffer) { DirectBufferUtil.clean(buffer); } buffer = null; channel = null; charBuffer = null; decoder = null; header = null; row = null; } /** * Method for getHeader. * * @return */ public DBFFileHeader getHeader() { return this.header; } /** * Query the reader as to whether there is another record. * * @return True if more records exist, false otherwise. */ public boolean hasNext() { return cnt < header.getNumRecords() + 1; } /** * Represent a Row in dbf file. * @author 2008-3-6 下午01:51:51 * */ public final class Row { /** * Read a row. * @param column * @return * @throws IOException */ public Object read(final int column) throws IOException { final int offset = getOffset(column); return readObject(offset, column); } /** * Method for getOffset. * * @param column * @return */ private int getOffset(final int column) { int offset = 1; for (int i = 0, ii = column; i < ii; i++) { offset += fieldLengths[i]; } return offset; } /** * (non-Javadoc). * @see java.lang.Object#toString() * @return . */ @Override public String toString() { final StringBuffer ret = new StringBuffer("DBF Row - "); for (int i = 0; i < header.getNumFields(); i++) { ret.append(header.getFieldName(i)).append(": \""); try { ret.append(this.read(i)); } catch (final IOException ioe) { ret.append(ioe.getMessage()); } ret.append("\" "); } return ret.toString(); } /** * Read a file object. * @param fieldOffset * @param fieldNum * @return * @throws IOException */ private Object readObject(final int fieldOffset, final int fieldNum) throws IOException { final char type = fieldTypes[fieldNum]; final int fieldLen = fieldLengths[fieldNum]; Object object = null; if (fieldLen > 0) { switch (type) { // (L)logical (T,t,F,f,Y,y,N,n) case 'l': case 'L': switch (charBuffer.charAt(fieldOffset)) { case 't': case 'T': case 'Y': case 'y': object = Boolean.TRUE; break; case 'f': case 'F': case 'N': case 'n': object = Boolean.FALSE; break; default: throw new IOException("Unknown logical value : '" + charBuffer.charAt(fieldOffset) + "'"); } break; // (C)character (String) case 'c': case 'C': // oh, this seems like a lot of work to parse strings...but, // For some reason if zero characters ( (int) char == 0 ) // are // allowed // in these strings, they do not compare correctly later on // down final int start = fieldOffset; final int end = fieldOffset + fieldLen - 1; // set up the new indexes for start and end charBuffer.position(start).limit(end + 1); final String s = new String(charBuffer.toString().getBytes("ISO-8859-1"), "gbk"); // this resets the limit... charBuffer.clear(); object = s; break; // (D)date (Date) case 'd': case 'D': try { String tempString = charBuffer.subSequence(fieldOffset, fieldOffset + 4).toString(); final int tempYear = Integer.parseInt(tempString); tempString = charBuffer.subSequence(fieldOffset + 4, fieldOffset + 6).toString(); final int tempMonth = Integer.parseInt(tempString) - 1; tempString = charBuffer.subSequence(fieldOffset + 6, fieldOffset + 8).toString(); final int tempDay = Integer.parseInt(tempString); final Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(Calendar.YEAR, tempYear); cal.set(Calendar.MONTH, tempMonth); cal.set(Calendar.DAY_OF_MONTH, tempDay); object = cal.getTime(); } catch (final NumberFormatException nfe) { // todo: use progresslistener, this isn't a grave error. } break; // (F)floating (Double) case 'n': case 'N': try { if (header.getFieldDecimalCount(fieldNum) == 0) { object = new Integer(extractNumberString(charBuffer, fieldOffset, fieldLen)); break; } // else will fall through to the floating point number } catch (final NumberFormatException e) { // Lets try parsing a long instead... try { object = new Long(extractNumberString(charBuffer, fieldOffset, fieldLen)); break; } catch (final NumberFormatException e2) { } } case 'f': case 'F': // floating point number try { object = new Double(extractNumberString(charBuffer, fieldOffset, fieldLen)); } catch (final NumberFormatException e) { // okay, now whatever we got was truly undigestable. // Lets go // with // a zero Double. object = new Double(0.0); } break; default: throw new IOException("Invalid field type : " + type); } } return object; } /** * @param charBuffer2 * TODO * @param fieldOffset * @param fieldLen */ private String extractNumberString(final CharBuffer charBuffer2, final int fieldOffset, final int fieldLen) { final String thing = charBuffer2.subSequence(fieldOffset, fieldOffset + fieldLen).toString().trim(); return thing; } } }
读取就用下面的代码来读,相应的exception和相关的引入类,自行引入,
FileChannel channel = (new FileInputStream("D:\\temp\\show2003.dbf")).getChannel(); DBFFileReader dbfreader = new DBFFileReader(channel,true); int fields = dbfreader.getHeader().getNumFields(); while(dbfreader.hasNext()) { DBFFileReader.Row row = dbfreader.readRow(); for (int i = 0; i < fields; i++) { System.out.print("["+row.read(i)+"] "); } } dbfreader.close(); channel.close();
评论
4 楼
laserdance
2008-07-09
要导入的包在下面
import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.security.AccessController; import java.security.PrivilegedAction; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
3 楼
laserdance
2008-07-09
楼上兄弟,谢谢你来看我的blog,我就写这下面吧,不给你发邮件了,请多多指教
public final class DirectBufferUtil { final static Logger logger = LoggerFactory.getLogger(DirectBufferUtil.class); /** * hidden Construct for DirectBufferUtil.java. */ private DirectBufferUtil() { } /** * 清除并释放DirectBuffer. 释放对应的channel后的资源. * * @param buffer * @return */ public static boolean clean(final ByteBuffer buffer) { if ((buffer == null) || !buffer.isDirect()) { return false; } final Boolean b = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { public Boolean run() { Boolean success = Boolean.FALSE; try { Method getCleanerMethod = buffer.getClass().getMethod("cleaner", (Class[]) null); getCleanerMethod.setAccessible(true); Object cleaner = getCleanerMethod.invoke(buffer, (Object[]) null); Method clean = cleaner.getClass().getMethod("clean", (Class[]) null); clean.invoke(cleaner, (Object[]) null); success = Boolean.TRUE; } catch (Exception e) { // logger error System.out.println(e.toString()); logger.error("clean fails for below "); logger.error(e.toString(),e); } return success; } }); return b.booleanValue(); } }
2 楼
ljhaabb
2008-06-06
我qq:346832751,希望得到你的帮助。谢谢
邮箱:ljhaabb@163.com
邮箱:ljhaabb@163.com
1 楼
ljhaabb
2008-06-06
哥们,你有DirectBufferUtil这个类的源代码吗?感谢共享.
发表评论
-
last year log statistics source code download
2009-07-31 16:48 892只提供两天下载,下周一就失效!! -
学习Apache Mina
2009-05-12 14:50 1759Mina的几个重要接口: I ... -
JFreechart V1.0.9 Guide(英文版)
2008-12-31 09:48 3293本人在0day上发现了JFreechart V1.0.9的Gu ... -
Java web 根据url下载文件IE出错,FF正常
2008-12-26 12:39 1932本人在web开发中,导出csv文件时遇到这一问题的,如下 当用 ... -
日志统计平台3之Jfreechart显示篇
2008-12-19 16:15 1583jfreechart功能十分强大了,在我们平台中用到了柱图和曲 ... -
日志统计平台2
2008-12-19 15:41 1404ImportTask里面我们就实现了ftp下载日志文件,然后批 ... -
日志统计平台
2008-12-19 14:12 1514这是一个商用的项目,是给XX证券用的.其实现的功能是,将各个服 ... -
(随时添加更新)本人code中积累或总结
2008-11-25 09:43 12841 一定要注意资源使用以后要释放,比如数据库的连接,流的使用, ... -
StringBuilder StringBuffer and "+"
2008-10-16 17:20 2077String字符串是Java中最常用的数据结构. " ... -
再用Maven2
2008-09-24 16:35 1614上次用Maven只是别人搭建好的工程,我们使用,今天项目不多, ... -
今天公司培训Scrum有感
2008-09-23 22:24 2623据说Scrum是一种敏捷的灵活的软件管理过程.你可以用它来迭代 ... -
定时执行调度任务
2008-07-21 15:36 2231这里我们用JDK 5.0里的ScheduledExecutor ... -
jdbc 分页
2008-07-20 00:34 3029在网上看了好多的分页程序,有好多hibernate的或是jdb ... -
IntrospectorCleanupListener 简介
2008-05-22 19:12 3489org.springframework.web.util.In ... -
*.sql的导入与导出
2008-01-24 09:49 992导出:x:\mysql\bin\mysqldump --dat ... -
java程序打开指定的网址
2008-01-24 09:43 16272007-04-19 13:57:42 import j ... -
tomcat5.0.*迁移Tomcat5.5.*的问题:jsp页面显示空白
2008-01-24 09:39 32482007-05-09 12:51:19 本机环境:Win ... -
在Tomcat中添加支持3GP/MP4格式文件的下载
2008-01-24 09:37 13774近日在工作中遇到3gp和mp4格式的文件问题。我用Nokia3 ... -
MySQL常用命令
2008-01-24 09:35 11422007-06-13 20:37:22 1.连接M ... -
Core Java:java除法中保持小数点位数的两种方法
2008-01-24 09:31 6410Method One: (double)(Mat ...
相关推荐
以下是一些关于如何在Java中读取DBF文件的关键知识点: 1. **依赖库**: 要读取DBF文件,你需要一个能够解析这种文件格式的库。Java社区中常用的库有JDBC-ODBC桥接、JDBF、Apache Commons DBF等。这些库提供了API...
`dbf-jdbc-wisecoders`是一个Java库,它提供了对DBF文件的读写功能,使得开发者能够通过Java语言方便地操作这些文件。 这个工具包的主要特点和功能包括: 1. **JDBC接口**:`dbf-jdbc-wisecoders`通过提供一个类似...
本篇文章将详细探讨如何使用Java来读写DBF文件,重点介绍xBaseJ库,这是一个专门为Java设计的、用于处理DBF文件的开源库。 首先,我们要理解DBF文件的结构。DBF文件是一种基于文本的数据库格式,由一系列记录组成,...
标题"Java读取DBF文件jar包和测试用例"表明我们要讨论的是一个Java库,它专门用于读取DBF文件,并且已经包含了测试代码来验证其功能。这个jar包名为"javadbf-0.4.0.jar",这可能是一个第三方库,它提供了Java API来...
在Java中处理DBF文件,我们可以借助特定的库,如JDBF,它提供了读取和写入DBF文件的功能。本篇文章将深入探讨如何使用Java实现DBF文件的读取与创建。 1. **DBF文件格式介绍** DBF文件格式源于dBase,是早期个人...
使用 Java 实现对 dbf 文件的简单读写 Java 是一种广泛使用的编程语言,对于读写 dbf 文件具有重要的应用价值。本文将介绍使用 Java 实现对 dbf 文件的简单读写,包括读写 dbf 文件的基本步骤、相关类的介绍、代码...
JavaDBF是一个Java库,专门用于读取和写入这些DBF文件,它为Java开发者提供了方便的API来处理这类文件。 首先,我们来了解DBF文件的基本结构。DBF文件通常包含一个表的结构信息和数据记录,每条记录由多个字段组成...
Java 解析 DBF 文件方案是使用 Java 语言来读取和解析 DBF 文件的方法。DBF 文件是一种常见的数据库文件格式,广泛应用于许多行业。为了读取和解析 DBF 文件,需要使用 Java 语言中的数据库连接和 SQL 语句。 在这...
Java读取DBF文件是数据库处理中的一个常见需求,特别是在处理一些旧的或者与特定硬件设备相关的数据时。DBF,全称为dBase File,是一种流行于20世纪80年代至90年代的数据库文件格式,常用于FoxPro、dBase等数据库...
Java读取DBF文件jar包javadbf.jar,像高考分数一般导出都是dbf文件。
原始的javadbf.jar可能存在读取DBF文件时编码转换不准确的问题,导致中文或者其他非ASCII字符显示为乱码。开发者通过识别并修复了这个问题,使得新的javadbf.jar能够正确地处理包含非ASCII字符的数据和表头,提高了...
DBF的ODBC建立方法: X86server,进入 控制面板--系统和安全--管理工具--ODBC数据源--右键管理员方式运行 X64(win7,server):C:\windows\sysWow64\odbcad32.exe 右键管理员方式运行,如图1 在"系统DSN"中找到刚...
在给定的压缩包`javadbf-0.4.0`中,可能包含了这个库的源代码、文档和相关的示例,这使得开发者能够理解和使用这个库来完成读写DBF文件的任务。 1. **读取DBF文件**: 使用`javadbf`库,你可以创建一个`DbfFile`...
这种方式通常不需要特殊的驱动或库支持,而是利用Java的基本I/O功能直接读取DBF文件的内容。这种方法适用于简单的数据处理任务,但可能不适用于复杂的数据结构分析或大型数据集处理。 ### 将DBF文件当作表进行操作...
打包文件路径 : dbf4j\artifacts\dbf4j_jar java -jar dbf4j.jar test.xml 20190416 test.xml 是配置文件,20190416是日期参数
`javadbf.jar`是一个Java库,它提供了对DBF文件的读取和写入功能。这个库使得Java开发者能够方便地操作DBF文件,而无需了解底层的文件格式细节。使用这个库,你可以创建新的DBF文件,向文件中添加记录,读取现有文件...
2. Java读取DBF的方法: 在Java中,没有内置的库直接支持DBF文件处理,但有第三方库如JDBF可以方便地进行读取操作。JDBF是一个轻量级的Java库,专门用于处理DBF文件。 3. 使用JDBF读取DBF步骤: a) 引入依赖:...
Java操作DBF文件的API是Java开发者用于读取和写入DBF(dBase文件格式)数据的重要工具。DBF是一种常见的数据库文件格式,广泛应用于早期的桌面数据库系统,如dBase、FoxPro等。在Java中处理这些文件通常需要第三方库...
本项目“java快速导出几十万百万生成DBF文件数据后台”主要关注如何使用Java编程语言高效地处理大规模数据,将其导出为DBF文件格式。 首先,我们需要了解Java处理大量数据的基本策略。在Java中,处理大数据的关键...
4. **文件I/O**:读取DBF文件时,会涉及到Java的文件I/O操作,如`java.io.File`类的使用,以及`InputStream`和`OutputStream`的子类,用于读写二进制数据。 5. **异常处理**:由于文件操作可能会出现各种异常,如...