DirectoryDataStore implements DataStore { public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); String shpDataStoreClassName = "org.geotools.data.shapefile.ShapefileDataStore"; DataStore ds = null; try { ds = (DataStore) Class.forName(shpDataStoreClassName).getConstructor(URL.class) .newInstance(f.toURL()); ds.createSchema(featureType); cache.refreshCacheContents(); } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } } DirectoryDataStore(File directory, URI namespaceURI); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
            Query query, Transaction transaction); FeatureSource<SimpleFeatureType, SimpleFeature> getFeatureSource(
            String typeName); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(
            String typeName, Filter filter, Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(
            String typeName, Transaction transaction); FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(
            String typeName, Transaction transaction); LockingManager getLockingManager(); SimpleFeatureType getSchema(String typeName); String[] getTypeNames(); FeatureSource<SimpleFeatureType, SimpleFeature> getView(Query query); void updateSchema(String typeName, SimpleFeatureType featureType); void createSchema(SimpleFeatureType featureType); void dispose(); FeatureSource<SimpleFeatureType, SimpleFeature> getFeatureSource(
            Name typeName); ServiceInfo getInfo(); List<Name> getNames(); SimpleFeatureType getSchema(Name name); void updateSchema(Name typeName, SimpleFeatureType featureType); DataStore getDataStore(String typeName);  }
@Test public void testCreateSchema() throws Exception { File dir = File.createTempFile("foo", "shp", new File("target")); dir.delete(); dir.mkdir(); DataStore ds = new DirectoryDataStore(dir, NSURI); assertEquals(0, ds.getTypeNames().length); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("foo"); tb.add("geom", Polygon.class); tb.add("bar", Integer.class); ds.createSchema(tb.buildFeatureType()); SimpleFeatureType ft = ds.getSchema("foo"); assertNotNull(ft); ds.dispose(); for (File f : dir.listFiles()) { f.delete(); } dir.delete(); }