PROBLEM
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.
Note:
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.
Code:
shapefile.reset();
int rec=0;
for(int i=0;i<shapefile.getNumRecs();i++){
int isOK=shapefile.getRecord();
if (isOK==Shapefile.OK)rec++;
}
//total # of records = rec
System.out.println(rec);
Article ID:000005619
Get help from ArcGIS experts
Download the Esri Support App