test.java

来自「rms常用操作例子,可通过这些例子修改成你想要的代码,绝对有用!」· Java 代码 · 共 63 行

JAVA
63
字号
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 + =
减小字号Ctrl + -
显示快捷键?