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

📄 addrecordmidlet.java

📁 j2me的程序
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
// A first MIDlet with simple text and a few commands.
public class addRecordMIDlet extends MIDlet
implements CommandListener {
  private Command exitCommand;
    //The display for this MIDlet
  private Display display;

  public addRecordMIDlet() {
    display = Display.getDisplay(this);
    exitCommand = new Command("离开", Command.SCREEN, 1);
   }

  // Start the MIDlet by creating the TextBox and
  // associating the exit command and listener.
  public void startApp() {
	TextBox aTextBox = new TextBox("主画面",null,256,TextField.ANY);

	RecordStore rs = null;
	byte[] nameEmail=null;
	boolean existingOrNot = false;
	boolean OK = true;

	existingOrNot = existing("aRS");
	if(existingOrNot){
	   try{
		rs = RecordStore.openRecordStore("aRS",false);
            }
            catch(Exception e){
		OK = false;
	   }
	   finally{
		 if(OK){
			 aTextBox.setString("aRS已存在并且已打开");
	          }
	          else{
			aTextBox.setString("aRS已存在但无法打开");
	          }
            }
        }
        else{
	try{
		rs = RecordStore.openRecordStore("aRS",true);
	    }
             catch(Exception e){
		OK = false;
	    }
	    finally{
		if(OK){
	    	aTextBox.setString("aRS虽未存在,但已创建并完成打开的操作!");
		}
		else{
	    	aTextBox.setString("aRS虽未存在,但无法创建,打开文件失败!");
		}
	}
	}

    if(OK)
       try{
	    	nameEmail = "JIDCA=login@ms16.hinet.net".getBytes();

			rs.addRecord(nameEmail,0,nameEmail.length);
			aTextBox.setString("已完成新增记录的操作");
		  }
	   catch(Exception e){
			aTextBox.setString("新增记录的操作失败");
	   }

    if(OK)
    	try{
		   rs.closeRecordStore();
	    }
	   catch(Exception e){
       }

    String result = new String(nameEmail);
	int position = result.indexOf('=');
	result = "姓名:" + result.substring(0,position) + "\n" +
	         "E-mail

⌨️ 快捷键说明

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