org.geotools.data.shapefile.dbf
Class IndexedDbaseFileReader
java.lang.Object
org.geotools.data.shapefile.dbf.DbaseFileReader
org.geotools.data.shapefile.dbf.IndexedDbaseFileReader
- All Implemented Interfaces:
- FileReader
public class IndexedDbaseFileReader
- extends DbaseFileReader
A DbaseFileReader is used to read a dbase III format file.
The general use of this class is:
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in )
Object[] fields = new Object[r.getHeader().getNumFields()];
while (r.hasNext()) {
r.readEntry(fields);
// do stuff
}
r.close();
For consumers who wish to be a bit more selective with their reading
of rows, the Row object has been added. The semantics are the same as using
the readEntry method, but remember that the Row object is always the same.
The values are parsed as they are read, so it pays to copy them out (as each
call to Row.read() will result in an expensive String parse).
EACH CALL TO readEntry OR readRow ADVANCES THE FILE!
An example of using the Row method of reading:
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in )
int fields = r.getHeader().getNumFields();
while (r.hasNext()) {
DbaseFileReader.Row row = r.readRow();
for (int i = 0; i < fields; i++) {
// do stuff
Foo.bar( row.read(i) );
}
}
r.close();
- Author:
- Ian Schneider, Tommaso Nolli
Methods inherited from class org.geotools.data.shapefile.dbf.DbaseFileReader |
close, fill, getHeader, hasNext, id, read, readEntry, readEntry, readEntry, readField, readRow, skip, transferTo |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IndexedDbaseFileReader
public IndexedDbaseFileReader(ShpFiles shpFiles)
throws java.io.IOException
- Like calling DbaseFileReader(ReadableByteChannel, true);
- Parameters:
channel
-
- Throws:
java.io.IOException
IndexedDbaseFileReader
public IndexedDbaseFileReader(ShpFiles shpFiles,
boolean useMemoryMappedBuffer)
throws java.io.IOException
- Creates a new instance of DBaseFileReader
- Parameters:
channel
- The readable channel to use.useMemoryMappedBuffer
- Wether or not map the file in memory
- Throws:
java.io.IOException
- If an error occurs while initializing.
IndexedDbaseFileReader
public IndexedDbaseFileReader(ShpFiles shpFiles,
boolean useMemoryMappedBuffer,
java.nio.charset.Charset stringCharset)
throws java.io.IOException
- Throws:
java.io.IOException
goTo
public void goTo(int recno)
throws java.io.IOException,
java.lang.UnsupportedOperationException
- Throws:
java.io.IOException
java.lang.UnsupportedOperationException
IsRandomAccessEnabled
public boolean IsRandomAccessEnabled()
main
public static void main(java.lang.String[] args)
throws java.lang.Exception
- Throws:
java.lang.Exception
Copyright © 1996-2010 Geotools. All Rights Reserved.