recordstorelist.java
来自「rms常用操作例子,可通过这些例子修改成你想要的代码,绝对有用!」· Java 代码 · 共 54 行
JAVA
54 行
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
public class RecordStoreList extends MIDlet {
public RecordStoreList(){}
public void startApp()throws MIDletStateChangeException {
RecordStore rs=null;
RecordEnumeration re=null;
try {
rs =RecordStore.openRecordStore("file1",true);
byte data [];
re=rs.enumerateRecords((RecordFilter)null,(RecordComparator)null,false);
System.out.println(re.numRecords()+" records are in the Record Store..");
System.out.println("records with even recordIds:");
for(int i=1;i<=re.numRecords();i++){
try{
int j=re.nextRecordId();
if(j%2==0){
data=rs.getRecord(j);
System.out.println("record "+j+" is retrieved..");
}
}catch (Exception e){}
}
System.out.println("records with odd recordIds:");
/*now the current pointer points to the last node of the
*enumerator.To use it again,you have to reset it.
*/
re.reset();
while(re.hasNextElement()){
try{
int j=re.nextRecordId();
if(j%2==1){
data=rs.getRecord(j);
System.out.println("record "+j+" is retrieved..");
}
}catch (Exception e){}
}
}catch(Exception e){}
finally{
//detroy the record enumerator
try {
re.destroy();
}catch(Exception e){}
//close the Record Store
try {
rs.closeRecordStore();
}catch (Exception e){}
}
destroyApp(true);
notifyDestroyed();
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?