📄 thunderdb.java
字号:
package thunder.bolt;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
import java.io.DataInputStream;
import javax.microedition.rms.*;
public class thunderDB {
private String thunderStr = "1";
private int thunderNumeric = 0;
private RecordStore rs = null;
public thunderDB() {
try {
rs = RecordStore.openRecordStore("thunder",true);
}catch(RecordStoreException rse) {}
/*if(distillRecordStore() == null)
addThunderRecord(this.thunderStr);
else this.thunderStr = distillRecordStore();*/
}
private String distillRecordStore() {
String thunderStrDistill = null;
int i = 1;
if(rs != null) {
try {
RecordEnumeration enum = rs.enumerateRecords(null,null,false);
while((i < 2)&&(enum.hasNextElement())) {
thunderStrDistill = new String(enum.nextRecord());
this.thunderNumeric = enum.nextRecordId();
i++;
}
}catch(Exception e) {}
}
return (String)(thunderStrDistill.trim());
}
private void addThunderRecord(String thunderStrNew) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
dos.writeUTF(thunderStrNew);
}catch(Exception e) {}
byte[] b = bos.toByteArray();
try {
rs.addRecord(b,0,b.length);
}catch(RecordStoreException rse) {}
}
private void updateThunderRecord(String thunderStrNew) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
try {
dos.writeUTF(thunderStrNew);
}catch(Exception e) {}
byte[] b = bos.toByteArray();
try {
rs.setRecord(1,b,0,b.length);
}catch(RecordStoreException rse) {}
}
public String getRecordStoreData() {
return distillRecordStore();
}
public boolean compareRecordStore(int pointNum) {
boolean flag = false;
int numPoint = 0;
String str = "";//distillRecordStore();
numPoint = (int)(Integer.parseInt(str));
if(pointNum > numPoint) {
updateThunderRecord(pointNum+"");
str = distillRecordStore();
flag = true;
}
return flag;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -