class FeatureCollectionExport {

    public boolean writeToShapefile() throws MalformedURLException, IOException {
        boolean success = false;
        //SimpleFeatureIterator features = simpleFeatureCollection.features();
        SimpleFeatureType type = buildFeatureType();
        FileDataStoreFactorySpi factory = FileDataStoreFinder.getDataStoreFactory("shp");
        File shpFile = checkAndCreateFile();
        Map datastoreConfig = new HashMap<>();
        datastoreConfig.put("url", shpFile.toURI().toURL());
        ShapefileDataStore shpfileDataStore = (ShapefileDataStore)factory.createNewDataStore(datastoreConfig);
        shpfileDataStore.createSchema(type);
        shpfileDataStore.forceSchemaCRS(this.crs);
        //DataStore dataStore = factory.createNewDataStore(datastoreConfig);
        SimpleFeatureStore featureStore = (SimpleFeatureStore) shpfileDataStore.getFeatureSource(type.getName());
        Transaction t = new DefaultTransaction();
        SimpleFeatureIterator fi = null;
        try { 
            // Copied directly from Import process
            featureStore.setTransaction(t);
            fi = simpleFeatureCollection.features();
            SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
            while (fi.hasNext()) {
                SimpleFeature source = fi.next();
                fb.reset();
                for (AttributeDescriptor desc : type.getAttributeDescriptors()) {
					Name attributeName = desc.getName();
					Object attributeValue = source.getAttribute(attributeName);
					if(null == attributeValue){
						attributeValue = NULL_PLACEHOLDER;
					}
                    fb.set(attributeName, attributeValue);
                }
                SimpleFeature target = fb.buildFeature(null);
                featureStore.addFeatures(DataUtilities.collection(target));
            }
            // successful if it made it this far
            success = true;
        } finally {
            t.commit();
            t.close();
            IOUtils.closeQuietly(fi);
        }
        return success;
    }

    public  FeatureCollectionExport(SimpleFeatureCollection simpleFeatureCollection,
            File outputDirectory, String namePrefix);
    public  FeatureCollectionExport(SimpleFeatureCollection simpleFeatureCollection,
            File outputDirectory, String namePrefix, boolean downloadAll);

}