code: public static boolean collectionToShapeFile( String shapeFilePath, CoordinateReferenceSystem crs,
              SimpleFeatureCollection fet ) throws IOException {
  
          // Create the file you want to write to
          File file = null;
          if (shapeFilePath.toLowerCase().endsWith(".shp")) { //$NON-NLS-1$
              file = new File(shapeFilePath);
          } else {
              file = new File(shapeFilePath + ".shp"); //$NON-NLS-1$
          }
  
          ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
  
          Map<String, Serializable> create = new HashMap<String, Serializable>();
          create.put("url", file.toURI().toURL());
          ShapefileDataStore newDataStore = (ShapefileDataStore) factory.createNewDataStore(create);
  
          newDataStore.createSchema(fet.getSchema());
          if (crs != null)
              newDataStore.forceSchemaCRS(crs);
          Transaction transaction = new DefaultTransaction();
          SimpleFeatureStore featureStore = (SimpleFeatureStore) newDataStore.getFeatureSource();
          featureStore.setTransaction(transaction);
          try {
              featureStore.addFeatures(fet);
              transaction.commit();
          } catch (Exception problem) {
              problem.printStackTrace();
              transaction.rollback();
          } finally {
              transaction.close();
          }
          return true;
      }
docs: <p>
  The easy way to create a shapefile from attributes and geometries
  </p>
  <p>
  <b>NOTE: this doesn't support date attributes</b>
  </p>
  
  @param shapeFilePath the shapefile name
  @param crs the destination crs
  @param fet the featurecollection
  @throws IOException