📄 rmsutil.java
字号:
package rms;
import javax.microedition.rms.*;
/**
* rms访问公用类
* @author hong
*
*/
public class RMSUtil {
public static RecordStore openRSAnymay(String rsname) {
RecordStore rs = null;
if (rsname.length() > 32)
return null;
try {
rs = RecordStore.openRecordStore(rsname, true);
return rs;
} catch (Exception e) {
return null;
}
}
public static RecordStore openRSExisted(String rsname) {
RecordStore rs = null;
if (rsname.length() > 32)
return null;
try {
rs = RecordStore.openRecordStore(rsname, false);
return rs;
} catch (Exception e) {
return null;
}
}
public static boolean deleteRS(String rsname) {
if (rsname.length() > 32)
return false;
try {
RecordStore.deleteRecordStore(rsname);
} catch (Exception e) {
return false;
}
return true;
}
public static int writeCharToRS(RecordStore rs,char data){
byte[] tmp=new byte[2];
tmp[0]=(byte)(0xff&(data>>8));
tmp[1]=(byte)(0xff&(data>>0));
try
{
return rs.addRecord(tmp,0,tmp.length);
}
catch (Exception e)
{
}
return -1;
}
public static char readCharFromRS(RecordStore rs,int recordid){
byte[] tmp=new byte[2];
try
{
tmp=rs.getRecord(recordid);
}
catch(Exception e)
{
}
char result=(char)(tmp[0]&0x00ff);
result=(char)((result<<8)+(char)(tmp[1]&0x00ff));
return result;
}
public static int writeIntToRS(RecordStore rs,int data){
byte[] tmp=new byte[4];
tmp[0]=(byte)(0xff&(data>>24));
tmp[1]=(byte)(0xff&(data>>16));
tmp[2]=(byte)(0xff&(data>>8));
tmp[3]=(byte)(0xff&(data>>0));
try
{
return rs.addRecord(tmp,0,tmp.length);
}
catch (Exception e)
{
}
return -1;
}
public static int readIntFromRS(RecordStore rs,int recordid){
byte[] tmp=new byte[4];
try
{
tmp=rs.getRecord(recordid);
}
catch(Exception e)
{
}
int result=(tmp[0]&0x0000ff);
result=(result<<8)+(tmp[1]&0x000000ff);
result=(result<<8)+(tmp[2]&0x000000ff);
result=(result<<8)+(tmp[3]&0x000000ff);
return result;
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -