Recently we are upgraded geotools version 2.0 to 9.3. While reading shape
file in 9.3 we are getting severe warning but not in geotools 2.0

7 Oct, 2013 4:31:41 PM org.geotools.data.shapefile.files.ShpFiles
logCurrentLockers
SEVERE: The following locker still has a lock: read on
file:/C:/Users/Administrator/Desktop/irumbaishp/irumbaishp/shape.shp by
org.geotools.data.shapefile.shp.ShapefileReader
7 Oct, 2013 4:31:41 PM org.geotools.data.shapefile.files.ShpFiles
logCurrentLockers
SEVERE: The following locker still has a lock: read on
file:/C:/Users/Administrator/Desktop/irumbaishp/irumbaishp/shape.shx by
org.geotools.data.shapefile.shp.IndexFile
7 Oct, 2013 4:31:41 PM org.geotools.data.shapefile.files.ShpFiles
logCurrentLockers
SEVERE: The following locker still has a lock: read on
file:/C:/Users/Administrator/Desktop/irumbaishp/irumbaishp/shape.dbf by
org.geotools.data.shapefile.dbf.DbaseFileReader



please help me
both sample code and shape file link is given below

https://docs.google.com/file/d/0B5Vh2tWJlQW_NmVrSk5ZWDFYLUU/edit?usp=drive_web&pli=1


.

code geotools 9

import java.io.File;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.data.simple.SimpleFeatureSource;

public class GeoOpen9
{

private static SimpleFeatureIterator simpleFeatureIterator;
 private static String fileName = "E:\\WorkSpace\\cland\\shape.shp";

 public static boolean openShapeFile() throws Exception
{
 File dataFile = new File(fileName);
dataFile.setReadOnly();
 ShapefileDataStore store = new ShapefileDataStore(dataFile.toURL());
SimpleFeatureSource source = store.getFeatureSource();
 SimpleFeatureCollection featureCollection = source.getFeatures();
 simpleFeatureIterator = featureCollection.features();
return true;
 }
public static  boolean iterate()
 {
while(simpleFeatureIterator.hasNext())
 {
simpleFeatureIterator.next();
 }

 simpleFeatureIterator.close();
return true;
 }
public static void main(String[] args)
 {
try
{
 System.out.println("reading");
GeoOpen9.openShapeFile();
 GeoOpen9.iterate();
System.out.println("Stopped");

}
 catch (Exception e)
{
 e.printStackTrace();
}
 }
}



getools 2.0


//Importing Shapefile packages/classes
//
import java.io.File;

import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureIterator;
import org.geotools.data.shapefile.ShapefileDataStore;
//
public class GeoOpen2
{
   private static FeatureIterator shapeFeatureIterator;
  private static String fileName = "E:\\WorkSpace\\cland\\shape.shp";
    /**
     * Reads the Data related to the next Plot from various data files
     *
     *  @return TRUE if properly read; Else FALSE
     */
    public static boolean openShapeFile() throws Exception
    {
        File dataFile = new File(fileName);
        ShapefileDataStore store = new ShapefileDataStore(dataFile.toURL());
        FeatureSource source =
store.getFeatureSource(store.getTypeNames()[0]);
        shapeFeatureIterator = source.getFeatures().collection().features();
        return true;
    }

    public static  boolean iterate()
    {
        while(shapeFeatureIterator.hasNext())
        {
            shapeFeatureIterator.next();
        }
        return true;
    }
    public static void main(String[] args)
    {
        try
        {
                  System.out.println("reading");
                GeoOpen2.openShapeFile();
                GeoOpen2.iterate();
                System.out.println("Stopped");
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
   }

}



shape file attached
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to