📄 rms.java
字号:
package com.cuilichen.usual;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
public class RMS {
public static final int Int1 = 0;
public static final int Int2 = 0;
public static final long Long1 = 0;
public static final String Str1 = "";
public static final String Str2 = "";
public static final String Str3 = "";
public static boolean addRecord(String name, int int1, int int2, long long1, String str1, String str2, String str3, boolean b) {
boolean success = false;
try {
RecordStore rs = RecordStore.openRecordStore(name, true);
Appointment app = new Appointment(int1, int2, long1, str1, str2, str3, b);
byte data[] = app.toBytes();
rs.addRecord(data, 0, data.length);
rs.closeRecordStore();
success = true;
} catch(Exception e) {
e.printStackTrace();
}
return success;
}
public static int getNumOfRecords(String name) {
try {
RecordStore rs = RecordStore.openRecordStore(name, true);
return rs.getNumRecords();
} catch(Exception e) {
return 0;
}
}
public static Appointment[] getRecords(String name) {
Appointment result[] = { };
try {
RecordStore rs = RecordStore.openRecordStore(name, false);
RecordEnumeration re = rs.enumerateRecords(null, null, false);
result = new Appointment[rs.getNumRecords()];
for(int i = 0; i < result.length; i++) {
int j = re.previousRecordId();
Appointment app = new Appointment(rs.getRecord(j));
result[i] = app;
//System.out.println("app["+i+"] "+app.getStr2());
}
rs.closeRecordStore();
} catch(Exception e) {
}
return result;
}
public static Appointment getRecord(String name, int j) {
Appointment result = new Appointment();
try {
RecordStore rs = RecordStore.openRecordStore(name, false);
RecordEnumeration re = rs.enumerateRecords(null, null, false);
result = new Appointment(rs.getRecord(j));
rs.closeRecordStore();
} catch(Exception e) {
}
return result;
}
public static int getIndex(String name, String content) {
RecordStore rs = null;
RecordEnumeration re = null;
try {
rs = RecordStore.openRecordStore(name, false); //open
re = rs.enumerateRecords(null, null, false); //enumeration
for(int i = 0; i < RMS.getNumOfRecords(name); i++) {
int j = re.nextRecordId();
Appointment app = new Appointment(rs.getRecord(j));
if(app.getStr1().equals(content)) {
return j;
}
}
} catch(Exception e) {
}
return 1;
}
public static boolean setRecord(String name, int id, int int1, int int2, long long1, String str1, String str2, String str3, boolean b) {
boolean success = false;
RecordStore rs = null;
RecordEnumeration re = null;
try {
rs = RecordStore.openRecordStore(name, false); //open
re = rs.enumerateRecords(null, null, false); //enumeration
Appointment app = new Appointment(int1, int2, long1, str1, str2, str3, b);
byte data[] = app.toBytes();
rs.setRecord(id, data, 0, data.length);
success = true;
rs.closeRecordStore();
} catch(Exception e) {
}
return success;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -