⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recordstorelist.java

📁 rms常用操作例子,可通过这些例子修改成你想要的代码,绝对有用!
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -