package com.conveyal.disser;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.Feature;

public class Disser {
    public static void main(String[] args) throws IOException {
    	if( args.length < 1 ) {
    		System.out.println( "usage: cmd shapfile" );
    		return;
    	}
    	
    	String shapefile_name = args[0];
    	
        File file = new File( shapefile_name );
        Map map = new HashMap();
        map.put( "url", file.toURL() );
        DataStore dataStore = DataStoreFinder.getDataStore( map );
        String typeName = dataStore.getTypeNames()[0];
        
        FeatureSource source = dataStore.getFeatureSource( typeName );

        FeatureCollection collection = source.getFeatures( );
        FeatureIterator iterator = collection.features();
        
        System.out.println( "here is a feature from the shapefile you gave" );
        while( iterator.hasNext() ){
             Feature feature = (Feature) iterator.next();
             System.out.println( feature );
             break;
        }

    }
}

@@ -68,24 +68,45 @@
 OException;%0A
+import java.net.URL;%0A
 import java.
@@ -685,16 +685,28 @@
      Map
+%3CString,URL%3E
  map = n
@@ -715,16 +715,28 @@
  HashMap
+%3CString,URL%3E
 ();%0A    
@@ -760,16 +760,24 @@
 %22, file.
+toURI().
 toURL() 
@@ -931,16 +931,22 @@
 reSource
+%3C?, ?%3E
  source 
@@ -1013,16 +1013,22 @@
 llection
+%3C?, ?%3E
  collect
@@ -1079,16 +1079,19 @@
 Iterator
+%3C?%3E
  iterato

use modern way to convert a filename to a URL; add types to generics