📄 save.java
字号:
import javax.microedition.rms.*;
public class Save {
public static RecordStore open(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 int writeChar2RS(RecordStore rs,char data) {
byte[]temp = new byte[2];
temp[0] = (byte)(0xff&(data >> 8));
temp[1] = (byte)(0xff&(data >> 0));
try {
return rs.addRecord(temp,0,temp.length);
}catch(Exception e){
}
return -1;
}
public static int writeInt2RS(RecordStore rs,int data) {
byte[]temp = new byte[4];
temp[0] = (byte)(0xff&(data >> 24));
temp[1] = (byte)(0xff&(data >> 16));
temp[2] = (byte)(0xff&(data >> 8));
temp[3] = (byte)(0xff&(data >> 0));
try {
return rs.addRecord(temp,0,temp.length);
}catch(Exception e){
}
return -1;
}
public static char readChar4RS(RecordStore rs,int recordID) {
byte[]temp = new byte[2];
try {
temp = rs.getRecord(recordID);
}catch(Exception e) {
}
char result = (char)(temp[0]&0x00ff);
result = (char)((result << 8) + (char)(temp[1]&0x00ff));
return result;
}
public static int readInt4RS(RecordStore rs,int recordID) {
byte[]temp = new byte[4];
try {
temp = rs.getRecord(recordID);
}catch(Exception e) {
}
int result = (temp[0]&0x00ff);
result = (result << 8) + (temp[1]&0x00ff);
result = (result << 8) + (temp[2]&0x00ff);
result = (result << 8) + (temp[3]&0x00ff);
return result;
}
public static int[] travelRS(RecordStore rs) {
int point = 0,i=0;
int ladder[] = {0,0,0,0,0};
byte[] temp;
try {
RecordEnumeration re = rs.enumerateRecords(null,null,false);
while(re.hasNextElement()) {
temp = re.nextRecord();
point = (temp[0]&0x00ff);
point = (point << 8) + (temp[1]&0x00ff);
point = (point << 8) + (temp[2]&0x00ff);
point = (point << 8) + (temp[3]&0x00ff);
if(ladder[0] < point) {
ladder[4] = ladder[3];
ladder[3] = ladder[2];
ladder[2] = ladder[1];
ladder[1] = ladder[0];
ladder[0] = point;
}
if(ladder[0] < point)
ladder[0] = point;
if((ladder[1] < point)&(ladder[0] != point))
ladder[1] = point;
if((ladder[2] < point)&(ladder[0] != point)&(ladder[1] != point))
ladder[2] = point;
if((ladder[3] < point)&(ladder[0] != point)&(ladder[1] != point)&(ladder[2] != point))
ladder[3] = point;
if((ladder[4] < point)&(ladder[0] != point)&(ladder[1] != point)&(ladder[2] != point)&(ladder[3] != point))
ladder[4] = point;
}
}catch(Exception e) {
}
return ladder;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -