im having trouble with the store of FileDataStore. It does the job for me but i found out that it throws java null pointer exception when i dispose it. I debbuged and im sure that the store is not null.
Here is my code :
SimpleFeatureIterator iterator = null;
FileDataStore store = null;
try {
store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource source = store.getFeatureSource();
for (int i = 0; i < store.getFeatureReader().getFeatureType().getAttributeDescriptors().size(); i++) {
names.add(store.getFeatureReader().getFeatureType().getAttributeDescriptors().get(i).getLocalName());
}
SimpleFeatureCollection features = source.getFeatures();
iterator = features.features();
while (iterator.hasNext()) {
// copy the contents of each feature and transform the geometry
SimpleFeature feature = iterator.next();
shapeFileData.add(feature.getAttributes());
}
} catch (IOException e) {
System.out.println(e.getLocalizedMessage());
e.printStackTrace();
}
iterator.close();
store.dispose();