?? rmsope.java
字號:
package AdressList;
import java.util.Vector;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;
public class RMSOpe {
private String storeName;
private RecordStore rs;
public RMSOpe(String storeName){
this.storeName = storeName;
}
public void openRecordStore(){//打開記錄集
try{
rs = RecordStore.openRecordStore(storeName, true);
}catch(Exception ex){
ex.printStackTrace();
}
}
public void addPhone(String name,String phone){//添加電話
String info = name + ":" + phone;
byte[] b = info.getBytes();
try{
rs.addRecord(b, 0, b.length);
}catch(Exception ex){
ex.printStackTrace();
}
}
public void deletePhone(String str){//刪除電話
int lastId = 0;
try{
lastId = rs.getNextRecordID();
}catch(Exception ex){
ex.printStackTrace();
}
for(int i=1;i<lastId;i++){
try{
byte[] b = rs.getRecord(i);
String recordStr = new String(b);
if(recordStr.equals(str)){
rs.deleteRecord(i);
}
}catch(Exception ex){}
}
}
public Vector getAllPhone(){//得到所有電話
Vector v = new Vector();
try{
RecordEnumeration re = rs.enumerateRecords(null,null,false);
while(re.hasNextElement()){
v.addElement(new String(re.nextRecord()));
}
}catch(Exception ex){
ex.printStackTrace();
}
return v;
}
public void closeRecordStore(){//關閉記錄集
try{
rs.closeRecordStore();
}catch(Exception ex){}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -