Hello,

I recently posted a question to GIS.Stackexchange here:
http://gis.stackexchange.com/questions/210781/geotools-collectionfeaturesource-disk-cleanup

but I figured I'd ask on the list as well.

I am loading a GeoJSON File into a FeatureSource and doing some work on
this FeatureSource.  When my work completes, I would like to delete this
GeoJSON file during cleanup. Here is my code:

FeatureJSON featureJSON = new FeatureJSON();
File geojsonFile = getFile(dataResource);
SimpleFeatureCollection featureCollection = (SimpleFeatureCollection)
featureJSON.readFeatureCollection(geojsonFile);
SimpleFeatureType featureSchema =
featureJSON.readFeatureCollectionSchema(geojsonFile, true);
FeatureSource<SimpleFeatureType, SimpleFeature> geojsonFeatureSource = new
CollectionFeatureSource(featureCollection);
// Begin work on the Feature Source

When I am done, I attempt to delete the GeoJSON file simply by:

geojsonFile.delete();

However, I cannot, as there is a lock on this file. When using previous
Data Stores (such as Shapefiles) I am always able to call dispose() on the
FeatureSource. However, in this GeoJSON case, I am not able to call
.dispose() on the CollectionFeatureSource because it is an "In Memory Data
Store".

If I am not able to call dispose(), then what can I do to free up this
Store?  Any help in freeing up the lock on this file so that I may delete
the GeoJSON file once my work is done?

Thanks for reading.
------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to