I have an RMS having 512 records as retrieved from
rs.getNumRecords();
But when I try to read the records using getRecordId(i)
or even if using
rs.enumerateRecords( null, null, false );
I get InvalidRecordIDException
, for records from 1 to 180, and I am able to read the records from 181 index to onwords.
I am not deleting the records anywhere in my application.
There have been instances of exiting the application in between while processing (reading this RMS), and overwriting the application.
I am closing the RMS at the end of my try block while reading the records.
Are there any possible reasons, of getting RMS corrupted or the particular indexes getting corrupted??
Code for reading the RMS using getRecord is
try {
RecordStore rs = RecordStore.openRecordStore(getTableName(), true);
ByteArrayInputStream inputStream = null;
DataInputStream inputDataStream = null;
int nor = rs.getNumRecords();
for(int i=1;i<=nor;i++)
{
System.out.println("i : "+i);
_recordByteArr = rs.getRecord(i);
inputStream = new ByteArrayInputStream(_recordByteArr);
inputDataStream = new DataInputStream(inputStream);
System.out.println("val at " + i + " ::" + new String(_recordByteArr));
//used inputDataStream.readUTF() here
}
if (inputDataStream != null) {
inputDataStream.close();
}
if (inputStream != null) {
inputStream.close();
}
rs.closeRecordStore();
} catch (Exception e) {
System.out.println("exp in read fieldtxn :" + e);
}