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

📄 test.java

📁 rms常用操作例子,可通过这些例子修改成你想要的代码,绝对有用!
💻 JAVA
字号:
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
import javax.microedition.io.*;

public class test extends MIDlet {

  public test(){}

  public void startApp()throws MIDletStateChangeException{

   RecordStore rs=null;

   try {
    rs = RecordStore.openRecordStore( "mydata", true );  
    // Write two records to the Record Store
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    DataOutputStream dout = new DataOutputStream( bout );
    byte[] data;

    dout.writeUTF( "this is a test" );
    dout.writeInt( 1 );
    dout.flush();
    data = bout.toByteArray();

    rs.addRecord( data, 0, data.length );

    bout.reset();
    dout.writeUTF( "this is another test" );
    dout.writeInt( 99 );
    dout.flush();
    data = bout.toByteArray();

    rs.addRecord( data, 0, data.length );
   
    // Now read through the Record Store

    Record record = new Record( rs );
    int lastID = rs.getNextRecordID();
    RecordEnumeration enum = rs.enumerateRecords(null, null,false);

    while( enum.hasNextElement() ){
        int id = enum.nextRecordId();
        record.moveTo( id );
        System.out.println( record.readUTF() + " " + 
                                    record.readInt() );
    }

    rs.closeRecordStore();
   }
   
   catch( Exception e ){
    // handle error
   }	


   destroyApp(true);
   notifyDestroyed();

 }
  public void pauseApp(){}
  public void destroyApp(boolean unconditional){}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -