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

📄 rmstore.java

📁 j2me radius soket radius client
💻 JAVA
字号:
package org.radiusClient.com;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import javax.microedition.io.*;
import java.io.*;
public class RMStore{
  private String cookie = null;
  private RecordStore rs = null;  
  private String name = null;
  public RMStore(String name)
  {
	this.name = name;
    openRecStore();         
  }
  
  public void openRecStore()
  {
    try
    {
      rs = RecordStore.openRecordStore(name, true);
    }
    catch (Exception e)
    {
    	e.printStackTrace();
    }
  }
  
  public void closeRecStore()
  {
    try
    {
      rs.closeRecordStore();
    }
    catch (Exception e)
    {
    	e.printStackTrace();
    }
  }

  public void writeRecord(String str)
  {
    byte[] rec = str.getBytes();

    try
    {
      rs.addRecord(rec, 0, rec.length);
    }
    catch (Exception e)
    {
       e.printStackTrace();
    }
  }

  public String readCookie(int i)
  {
    try
    {
      byte[] recData = new byte[25]; 
      int len;

      if (rs.getNumRecords() > 0)
      {      
        if (rs.getRecordSize(i) > recData.length)
          recData = new byte[rs.getRecordSize(i)];
        len = rs.getRecord(i, recData, 0);

        String cook = new String(recData);
        return cook;
      }
      
    }
    catch (Exception e)  {
       e.printStackTrace();
    }
    return "no record";
  }
  
  public int getNum()
  {
	  try {
		return rs.getNumRecords();
	} catch (RecordStoreNotOpenException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return 0;
  }

}


⌨️ 快捷键说明

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