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


Java RecordStore.getRecord方法代码示例

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


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

示例4: 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

示例5: h

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

示例6: load

import javax.microedition.rms.RecordStore; //导入方法依赖的package包/类
private void load() {
	RecordStore recordStore = null;
	try {
		recordStore = RecordStore.openRecordStore(recordStoreName, false);
		String message;
		if (recordStore.getNumRecords() > 0) {
			int recordId = 1;
			System.out.println("getRecord " + recordId);
			byte[] data = recordStore.getRecord(recordId);
			message = recordId + " loaded";
			stringItem.setText(new String(data));
			
			if (savedRecordId != recordId) {
				messageItem.setText("recordId " + recordId + " is different " + savedRecordId);
			}
			
		} else {
			message = "recordStore empty";
			stringItem.setText("");
		}
		messageItem.setText(message);
	} catch (Throwable e) {
		System.out.println("error accessing RecordStore");
		e.printStackTrace();
		messageItem.setText(e.toString());
	} finally {
		closeQuietly(recordStore);
	}
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:30,代码来源:RecordStoreForm.java


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