As replied to me by Larry:
ShapefileDataStore can put information to the DBF file, and can read
from it too. Of course with the ShapefileDataStore you'll also need
the shp and shx files as well. Here's a simple example of reading the
feature attribute information (stored in the DBF in a shapefile) using
ShapefileDataStore:
URL shapeURL = new URL("file:///tmp/myshapefile.shp");
ShapefileDataStore store = new ShapefileDataStore(shapeURL);
String name = store.getTypeNames()[0];
FeatureSource source = store.getFeatureSource(name);
FeatureCollection shapeCollection = source.getFeatures();
System.out.println(shapeCollection.size() + " features returned
from query.");
System.out.println();
FeatureIterator iterator = shapeCollection.features();
while(iterator.hasNext())
{
Feature feature = iterator.next();
String field1 = (String) feature.getAttribute("field1");
Integer field2 = (Integer) feature.getAttribute("field2");
System.out.println("field1 is: " + field1);
System.out.println("field2 is: " + field2);
}
-Larry
Thanks a lot! This makes it very clear!
--
View this message in context:
http://n2.nabble.com/Read-data-from-dbf-file-tp4902284p4925837.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users