⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createaddressbook.java

📁 7个J2ME例子
💻 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;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -