Is This Content Helpful?
We're glad to know this article was helpful.
After a record is deleted from a shape file using 'com.esri.mo.file.shp.Shapefile.delRecord(int recNum)' method and 'getNumRecs()' method is called on the same object, the total number of records will remain same.
In MapObjects Java 2.0, Shapefile class is within com.esri.mo2.file.shp package.
Shapefile.delRecord(int rec) only flags the record as deleted but does not remove it permanently from the file. Shapefile.getNumRecs() method will return the number of records stored in the header of the shape file, which only stores the total number of records, including those flagged as deleted.
Use for-loop to go through all the records in the shapefile and count only those that return the status as OK as shown in the following example:
//total # of records = rec