problems with record Store Reading
Hi
I have problems reading record store properly with recordstoreenumeration
Here is the code
String outString[] = {"First Record","Second Record","Third Record"};
int outInteger[] = {15,10,5};
boolean outBoolean[] = {true,false,true};
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DataOutputStream outDataStream = new DataOutputStream(outStream);
for(int x=0;x<3;x++){
outDataStream.writeUTF(outString[x]);
outDataStream.writeBoolean(outBoolean[x]);
outDataStream.writeInt(outInteger[x]);
outDataStream.flush();
outRecord = outStream.toByteArray();
rs.addRecord(outRecord,0,outRecord.length);
}
outStream.reset();
outStream.close();
outDataStream.close();
StringBuffer buffer = new StringBuffer();
byte[] byteInData = new byte[300];
ByteArrayInputStream inStream = new ByteArrayInputStream(byteInData);
DataInputStream inDataStream = new DataInputStream(inStream);
rEnum = rs.enumerateRecords(null,null,false);
System.out.println("Number of records are " + rEnum.numRecords());
while(rEnum.hasNextElement())
{
int id = rEnum.nextRecordId();
System.out.println("The record id is " + id);
rs.getRecord(id,byteInData,0);
System.out.println("Reading in jobsReader " + inDataStream.readUTF() + " " +inDataStream.readBoolean()+ " " +inDataStream.readInt());
}
inStream.close();
inDataStream.close();
I run this code three times so I get 9 records, but for some mystikal reason It reads from to down starting with record ID = 9 and reads only the records that were insterted latest. Here is the output:
Number of records are 9
The record id is 9
Reading in jobsReader First Record true 15
The record id is 8
Reading in jobsReader Second Record false 10
The record id is 7
Reading in jobsReader Third Record true 5
The record id is 6
Reading in jobsReader false 0
The record id is 5
Reading in jobsReader false 0
The record id is 4
Reading in jobsReader false 0
The record id is 3
Reading in jobsReader false 0
The record id is 2
Reading in jobsReader false 0
The record id is 1
Reading in jobsReader false 0
I have been struggling with this for about two days, still no success. Please help me to sort this out.

