rmstore.java
来自「j2me radius soket radius client」· Java 代码 · 共 94 行
JAVA
94 行
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 + =
减小字号Ctrl + -
显示快捷键?