?? createaddressbook.java
字號:
/* * Copyright (c) 2000-2001 Sun Microsystems, Inc. All Rights Reserved. */package examples.addressbook;import java.lang.*;import java.io.*;import java.util.*;import javax.microedition.rms.*;/** * Static helper class that creates a record * store from data in an array. */class CreateAddressBook { // Don't allow this class to be instantiated private CreateAddressBook() {} /** * Helper method that creates a record * store from data in an array. * Returns: * true if RMS store was created * false otherwise * name the name of the record store to create * seedData an array w/ data to seed record store */ static boolean createRecordStore(String name, String[] seedData) { RecordStore recordStore; boolean ret = false; // Delete any previous record store with same name. // Silently ignore failure. try { RecordStore.deleteRecordStore(name); } catch (Exception rse) {} // Create new RMS store. If we fail, return false. try { recordStore = RecordStore.openRecordStore(name, true); } catch (RecordStoreException rse) { return ret; } ret = true; // assume success // Now, populate the record store with the seed data for (int i = 0; i < seedData.length; i += 3) { byte[] record = SimpleRecord.createRecord(seedData[i], seedData[i+1], seedData[i+2]); try { recordStore.addRecord(record, 0, record.length); } catch (RecordStoreException rse) { ret = false; break; } } // Get here when adds are complete, or an error occured. // In any case, close the record store. We shouldn't // have a failure, so silently ignore any exceptions. try { recordStore.closeRecordStore(); } catch (RecordStoreException rsne) {} return ret; }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -