private void LoadStore() {
RecordStore store = null;
ByteArrayInputStream bin = null;
DataInputStream din = null;
try {
store = RecordStore.openRecordStore("GibsonEnterBobo", true);
if (store.getNumRecords() == 0) {
store.closeRecordStore();
return;
}
bin = new ByteArrayInputStream(store.getRecord(1));
din = new DataInputStream(bin);
try {
userName = din.readUTF();
password = din.readUTF();
} catch (Exception ex1) {
}
} catch (Exception ex) {
} finally {
if (din != null) {
try {
din.close();
} catch (IOException ex3) {
}
din = null;
}
if (bin != null) {
try {
bin.close();
} catch (IOException ex4) {
}
bin = null;
}
if (store != null) {
try {
store.closeRecordStore();
} catch (Exception ex2) {
}
store = null;
}
}
}
private void SaveStore() {
RecordStore store = null;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dout = new DataOutputStream(bout);
try {
dout.writeUTF(userName);
dout.writeUTF(password);
store = RecordStore.openRecordStore("GibsonEnterBobo", true);
byte[] arr = bout.toByteArray();
if (store.getNumRecords() == 0) {
store.addRecord(arr, 0, arr.length);
} else {
store.setRecord(1, arr, 0, arr.length);
}
} catch (Exception ex) {
} finally {
if (dout != null) {
try {
dout.close();
} catch (IOException ex3) {
}
dout = null;
}
if (bout != null) {
try {
bout.close();
} catch (IOException ex4) {
}
bout = null;
}
if (store != null) {
try {
store.closeRecordStore();
} catch (Exception ex2) {
}
store = null;
}
}
}
2005-12-13 17:33:43
Views(1113)
Comments