当前位置: 首页>>代码示例>>Java>>正文


Java RecordStore.closeRecordStore方法代码示例

本文整理汇总了Java中javax.microedition.rms.RecordStore.closeRecordStore方法的典型用法代码示例。如果您正苦于以下问题:Java RecordStore.closeRecordStore方法的具体用法?Java RecordStore.closeRecordStore怎么用?Java RecordStore.closeRecordStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.rms.RecordStore的用法示例。


在下文中一共展示了RecordStore.closeRecordStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAddRecordDeleteRecord1

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddRecordDeleteRecord1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testAddRecordDeleteRecord1";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int count = 0;
    long startingSequence = ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue();
    while ((ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue() - startingSequence) < erasedSequenceCount) {
        fill(record, count);
        int recordId = store.addRecord(record, 0, record.length);
        fill(record, (byte) (count+1));
        byte[] bytes = store.getRecord(recordId);
        assertEquals(record, record.length, (byte) (count + 1));
        assertEquals(bytes, bytes.length, (byte) count);
        store.deleteRecord(recordId);
        try {
            store.getRecord(recordId);
            fail();
        } catch (InvalidRecordIDException e) {
        }
        count++;
    }
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:27,代码来源:RecordStoreIntegrationTest.java

示例2: testSetRecord1

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testSetRecord1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testSetRecord1";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int count = 0;
    int recordId = store.addRecord(record, 0, record.length);
    long startingSequence = ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue();
    while ((ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue() - startingSequence) < erasedSequenceCount) {
        fill(record, count);
        store.setRecord(recordId, record, 0, record.length);
        byte[] bytes = store.getRecord(recordId);
        assertEquals(bytes, bytes.length, count);
        count++;
    }
    assertTrue(count > 0);
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:21,代码来源:RecordStoreIntegrationTest.java

示例3: readbestscore

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * ��ȡ�����Ϸ��¼
 * @return ��ѷ���
 * @throws RecordStoreException 
 * @throws  
 * @throws Exception 
 */
private int readbestscore() throws Exception
{
	RecordStore rsb=RecordStore.openRecordStore("DanceBest", true);
	RecordEnumeration renum= rsb.enumerateRecords(null, null, false);
	if(renum.hasNextElement())
	{
		System.out.println("��ȡ��Ѽ�¼��...");
		int temp= Integer.parseInt(new String(renum.nextRecord()));
		rsb.closeRecordStore();
		return temp;
	}
	else
	{
		System.out.println("û����Ѽ�¼...");
		rsb.closeRecordStore();
		return 0;
	}
	
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:27,代码来源:Main.java

示例4: flush

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public void flush() throws IOException {
    if(cache != null) {
        byte[] data = cache.toByteArray();
        if(data.length > 0) {
            RecordStore r = null;
            try {
                r = RecordStore.openRecordStore("" + letter + key, true);
                r.addRecord(data, 0, data.length);
                r.closeRecordStore();
                if(letter == 'Z') {
                    letter = 'a';
                } else {
                    letter++;
                }
                cache = new ByteArrayOutputStream();
            } catch (RecordStoreException ex) {
                ex.printStackTrace();
                cleanup(r);
                throw new IOException(ex.toString());
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:GameCanvasImplementation.java

示例5: flush

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public void flush() throws IOException {
    if (cache != null) {
        byte[] data = cache.toByteArray();
        if (data.length > 0) {
            RecordStore r = null;
            try {
                r = RecordStore.openRecordStore("" + letter + key, true);
                r.addRecord(data, 0, data.length);
                r.closeRecordStore();
                if (letter == 'Z') {
                    letter = 'a';
                } else {
                    letter++;
                }
                cache.reset();
            } catch (RecordStoreException ex) {
                ex.printStackTrace();
                cleanup(r);
                throw new IOException(ex.toString());
            }
        }
    }
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:24,代码来源:BlackBerryImplementation.java

示例6: panic

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
/**
 * called when an attempt to write to the log fails
 */
public void panic () {
    final String LOG_PANIC = "LOG_PANIC";

    try {
        RecordStore store = RecordStore.openRecordStore(LOG_PANIC, true);

        int time = (int)(System.currentTimeMillis() / 1000);
        byte[] record = new byte[] {
            (byte)((time / 16777216) % 256),
            (byte)((time / 65536) % 256),
            (byte)((time / 256) % 256),
            (byte)(time % 256)
        };
        store.addRecord(record, 0, record.length);

        store.closeRecordStore();
    } catch (RecordStoreException rse) {
        throw new WrappedException(rse);
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:J2MELogger.java

示例7: Config

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public Config(WandersmannMIDlet midlet) {
	this.midlet = midlet;
	try {
		RecordStore config = RecordStore.openRecordStore("config", true);
		
		RecordEnumeration configKeys = config.enumerateRecords(null, null, false);
		while(configKeys.hasNextElement()) {
			String kv = new String(configKeys.nextRecord());
			Vector vkv = StringTokenizer.getVector(kv, "=");
			keys.put(vkv.elementAt(0), vkv.elementAt(1));
		}
		
		configKeys.destroy();
		config.closeRecordStore();
	} catch(RecordStoreException ex) {
		midlet.getDebugDialog().addMessage("Exception", ex.getMessage());
	}
}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:19,代码来源:Config.java

示例8: store

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
private void store() {
	try {
		RecordStore.deleteRecordStore("config");
		RecordStore config = RecordStore.openRecordStore("config", true);

		Enumeration k = this.keys.keys();
		while(k.hasMoreElements()) {
			String key = (String)k.nextElement();
			byte[] buf = (key + "=" + (String)this.keys.get(key)).getBytes();
			config.addRecord(buf, 0, buf.length);
		}

		config.closeRecordStore();
	} catch(RecordStoreException ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:cli,项目名称:worldmap-classic,代码行数:18,代码来源:Config.java

示例9: writeRecordStore

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public final void writeRecordStore() {
    try {
        RecordStore store;
        RecordEnumeration rEnum = (store = RecordStore.openRecordStore("options", false)).enumerateRecords((RecordFilter) null, (RecordComparator) null, false);

        while (rEnum.hasNextElement()) {
            store.deleteRecord(rEnum.nextRecordId());
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos;
        (dos = new DataOutputStream(baos)).writeBoolean(this.field_30);
        dos.writeBoolean(this.field_31);
        dos.writeInt(this.field_9);
        dos.writeInt(this.field_10);
        store.addRecord(baos.toByteArray(), 0, baos.toByteArray().length);
        store.closeRecordStore();
    } catch (Exception e) {
        System.err.println(e);
        e.printStackTrace();
    }
}
 
开发者ID:NaikSoftware,项目名称:Blitzkrieg,代码行数:23,代码来源:GameCanvas.java

示例10: InstallCfg

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public InstallCfg() throws IOException {
	try {
		RecordStore rs = RecordStore.openRecordStore(INSTALLINFO, false);
		try {
			config = Installer.parseConfig(new ByteArrayInputStream(rs.getRecord(1)));
			// for compatibility with Release 2.1
			if (config.get("alchemy.version") != null) {
				config.set(Installer.VERSION, config.get("alchemy.version"));
				config.remove("alchemy.version");
			}
		} finally {
			rs.closeRecordStore();
		}
		isInstalled = true;
	} catch (RecordStoreNotFoundException rsnfe) {
		// ok, not installed
		config = new HashMap();
		isInstalled = false;
	} catch (Exception e) {
		throw new IOException(e.toString());
	}
}
 
开发者ID:SBasalaev,项目名称:alchemy-os,代码行数:23,代码来源:InstallCfg.java

示例11: save

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
public void save() throws IOException {
	try {
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		Object[] keys = config.keys();
		for (int i=0; i<keys.length; i++) {
			IO.println(out, "" + keys[i] + '=' + config.get(keys[i]));
		}
		RecordStore rs = RecordStore.openRecordStore(INSTALLINFO, true);
		if (rs.getNextRecordID() == 1) rs.addRecord(null, 0, 0);
		byte[] data = out.toByteArray();
		rs.setRecord(1, data, 0, data.length);
		rs.closeRecordStore();
		isInstalled = true;
	} catch (Exception e) {
		throw new RuntimeException(e.toString());
	}
}
 
开发者ID:SBasalaev,项目名称:alchemy-os,代码行数:18,代码来源:InstallCfg.java

示例12: testAddRecordDeleteRecord2

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddRecordDeleteRecord2() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    String storeName = "testAddRecordDeleteRecord2";
    RecordStore store = RecordStore.openRecordStore(storeName, true);
    byte[] record = new byte[1024];
    int firstCountAdd = -1;
    for (int i=0; i < 4; i++) {
        int countAdd = 0;
        try {
            while (true) {
                fill(record, countAdd);
                store.addRecord(record, 0, record.length);
                countAdd++;
            }
        } catch (RecordStoreFullException e) {
        }
        assertTrue(countAdd > 0);
        if (firstCountAdd == -1) {
            firstCountAdd = countAdd;
        } else {
            assertEquals(firstCountAdd, countAdd);
        }
        RecordEnumeration records = store.enumerateRecords(null, null, false);
        int countDelete = 0;
        while (records.hasNextElement()) {
            int recordId = records.nextRecordId();
            byte[] bytes = store.getRecord(recordId);
            assertEquals(bytes, bytes.length, countDelete);
            store.deleteRecord(recordId);
            countDelete++;
        }
        assertEquals(countDelete, countAdd);
    }
    store.closeRecordStore();
    RecordStore.deleteRecordStore(storeName);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:38,代码来源:RecordStoreIntegrationTest.java

示例13: testAddRecordDeleteStore1

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddRecordDeleteStore1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    byte[] record = new byte[1024];
    int firstCountAdd = -1;
    for (int i=0; i < 4; i++) {
        String storeName = "testAddRecordDeleteStore1";
        RecordStore store = RecordStore.openRecordStore(storeName, true);
        int countAdd = 0;
        try {
            while (true) {
                fill(record, countAdd);
                store.addRecord(record, 0, record.length);
                countAdd++;
            }
        } catch (RecordStoreFullException e) {
        }
        assertTrue(countAdd > 0);
        if (firstCountAdd == -1) {
            firstCountAdd = countAdd * 90 / 100;
        } else {
            assertTrue(countAdd >= firstCountAdd);
        }
        store.closeRecordStore();
        RecordStore.deleteRecordStore(storeName);
    }
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:28,代码来源:RecordStoreIntegrationTest.java

示例14: testAddStoreDeleteStore1

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
@Test
public void testAddStoreDeleteStore1() throws RecordStoreException {
    assertNull(RecordStore.listRecordStores());
    int count = 0;
    long startingSequence = ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue();
    while ((ImpGlobal.getRecordStoreManagerErasedSequenceCurrentValue() - startingSequence) < erasedSequenceCount) {
        String storeName = "testAddStoreDeleteStore1_" + count;
        RecordStore store = RecordStore.openRecordStore(storeName, true);
        store.closeRecordStore();
        RecordStore.deleteRecordStore(storeName);
        count++;
    }
    assertTrue(count > 0);
}
 
开发者ID:tomatsu,项目名称:squawk,代码行数:15,代码来源:RecordStoreIntegrationTest.java

示例15: g

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
void g() {
  RecordStore rs = RecordStore.openRecordStore("popeye", true);
  try {
    rs.getRecord(1);
  } finally {
    rs.closeRecordStore();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:RecordStoreResource.java


注:本文中的javax.microedition.rms.RecordStore.closeRecordStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。