I am using GeoTools for merging my individual shapefiles but I get an exception when the size of the shapefile increases beyond 2GB.
How can I do this using Geotools?
I am using GeoTools for merging my individual shapefiles but I get an exception when the size of the shapefile increases beyond 2GB.
How can I do this using Geotools?
As everyone said in the comments - you can't. Shapefiles use a 32bit pointer internally and it breaks if you go over 2Gb. Switch to a GeoPackage, fortunately as Datastores are interchangeable all you will need to do is change the parameters you are creating it with.
HashMap<String, Object> map = new HashMap<>();
map.put(GeoPkgDataStoreFactory.DBTYPE.key, "geopkg");
map.put(GeoPkgDataStoreFactory.DATABASE.key, outFile);
Datastore store = DataStoreFinder.getDataStore(map);