📄 rms.java
字号:
package com.cuilichen.usual;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
public class RMS {
private static String name = "";
public static boolean addRecord(int int1, int int2, long long1, String str1, String str2, String str3, boolean b) throws RecordStoreException {
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) {
throw new RecordStoreException("addREx");
}
return success;
}
public static int getNumOfRecords() throws RecordStoreException {
int result = 0;
try {
RecordStore rs = RecordStore.openRecordStore(name, false);
result = rs.getNumRecords();
} catch(Exception e) {
throw new RecordStoreException("getRNumEx");
}
return result;
}
public static Appointment[] getRecords() throws RecordStoreException {
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;
}
rs.closeRecordStore();
} catch(Exception e) {
throw new RecordStoreException("getRsEx");
}
return result;
}
public static boolean setRecord(int id, int int1, int int2, long long1, String str1, String str2, String str3, boolean b) throws RecordStoreException {
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) {
throw new RecordStoreException("setREx");
}
return success;
}
public static String getName() {
return name;
}
public static void setName(String name) {
RMS.name = name;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -