thanks







/*- – - – - – – - – – - – – - – – - – – - – – - – – - – – - – – - – – - -

Please consider your environmental responsibility.
Before printing this e-mail message, ask yourself whether you really need a
hard copy.

Life is what happens to you, while you're busy making other plans

We do not inherit the earth from our ancestors; we borrow it from our
children.
Leave them a living planet reduce your carbon foot print.
------------------------------------------------------------
--------------------------------*/






yours suri chinna


On Mon, Oct 7, 2013 at 6:03 PM, sunish <sunish.ku...@gmail.com> wrote:

> Disposing the datastore after use solves the problem.
>
>
> package org.geotools.tutorial;
>
> import java.io.File;
>
> import org.geotools.data.FileDataStore;
> import org.geotools.data.FileDataStoreFinder;
>
> import org.geotools.data.shapefile.ShapefileDataStore;
> import org.geotools.data.simple.SimpleFeatureCollection;
> import org.geotools.data.simple.SimpleFeatureIterator;
> import org.geotools.data.simple.SimpleFeatureSource;
>  import org.opengis.feature.simple.SimpleFeature;
>
> public class GeoOpen
> {
>
>     private static SimpleFeatureIterator simpleFeatureIterator;
>     private static String fileName = "/home/sunish/Temp/shape.shp";
>     static FileDataStore store ;
>
>     public  static boolean openShapeFile() throws Exception
>     {
>         File dataFile = new File(fileName);
>         dataFile.setReadOnly();
>         store = FileDataStoreFinder.getDataStore(dataFile);
>        // ShapefileDataStore store = new
> ShapefileDataStore(dataFile.toURL());
>
>         SimpleFeatureSource source = store.getFeatureSource();
>         SimpleFeatureCollection featureCollection = source.getFeatures();
>         simpleFeatureIterator = featureCollection.features();
>
>
>         return true;
>     }
>     public  static boolean iterate()
>     {
>         try{
>         while(simpleFeatureIterator.hasNext())
>         {
>
>             SimpleFeature f = simpleFeatureIterator.next();
>
>            System.out.println(""+f.getID()+" - "+f.getAttribute("KIDE"));
>         }
>         }
>         catch(Exception ex){
>             ex.printStackTrace();
>         }
>         finally{
>             simpleFeatureIterator.close();
>             store.dispose();
>
>         }
>
>
>         return true;
>     }
>     public static void main(String[] args) {
>         try {
>             for(int i=0;i<10000;i++){
>             System.out.println("reading "+ i);
>
>             GeoOpen.openShapeFile();
>             GeoOpen.iterate();
>
>             System.out.println("Stopped");
>             //Thread.sleep(1000);
>             }
>
>         } catch (Exception e) {
>             // TODO Auto-generated catch block
>             e.printStackTrace();
>         }
>     }
> }
>
>
>
>
> On Mon, Oct 7, 2013 at 4:35 PM, suri <surendranath1...@gmail.com> wrote:
>
>> 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
>> GeoTools-GT2-Users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>
>
------------------------------------------------------------------------------
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=60134071&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to