Java Code Examples for javax.microedition.rms.RecordStoreException#printStackTrace()

The following examples show how to use javax.microedition.rms.RecordStoreException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
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());
            }
        }
    }
}
 
Example 2
Source File: BlackBerryImplementation.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
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());
            }
        }
    }
}
 
Example 3
Source File: RecordStoreImpl.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
@Override
public int getSize()
		throws RecordStoreNotOpenException {
	if (!open) {
		throw new RecordStoreNotOpenException();
	}

	// TODO include size overhead such as the data structures used to hold the state of the record store

	// Preload all records
	enumerateRecords(null, null, false);

	int result = 0;
	Enumeration keys = records.keys();
	while (keys.hasMoreElements()) {
		int key = (Integer) keys.nextElement();
		try {
			byte[] data = getRecord(key);
			if (data != null) {
				result += data.length;
			}
		} catch (RecordStoreException e) {
			e.printStackTrace();
		}
	}
	return result;
}
 
Example 4
Source File: GameCanvasImplementation.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public RMSInputStream(short key) throws IOException {
            this.key = key;
            RecordStore r = null;
            RecordEnumeration e = null;
            char letter = 'A';
            try {
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                r = open("" + letter + key);
                while(r != null) {
                    e = r.enumerateRecords(null, null, false);
                    while(e.hasNextElement()) {
                        byte[] data = e.nextRecord();
                        os.write(data);
                    }
                    e.destroy();
                    r.closeRecordStore();
                    letter++;
                    r = open("" + letter + key);
                    if(letter == 'Z') {
                        letter = 'a' - ((char)1);
                    }
                }
                os.close();
                current = new ByteArrayInputStream(os.toByteArray());
            } catch (RecordStoreException ex) {
                //#ifndef RIM
                ex.printStackTrace();
                //#else
//#                 System.out.println("Exception in object store input stream constructor: " + ex);
                //#endif
                cleanup(r);
                cleanup(e);
                throw new IOException(ex.toString());
            }
        }
 
Example 5
Source File: BlackBerryImplementation.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public RMSInputStream(short key) throws IOException {
    this.key = key;
    RecordStore r = null;
    RecordEnumeration e = null;
    char letter = 'A';
    try {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        r = open("" + letter + key);
        while (r != null) {
            e = r.enumerateRecords(null, null, false);
            while (e.hasNextElement()) {
                byte[] data = e.nextRecord();
                os.write(data);
            }
            e.destroy();
            r.closeRecordStore();
            letter++;
            r = open("" + letter + key);
            if (letter == 'Z') {
                letter = 'a' - ((char) 1);
            }
        }
        os.close();
        current = new ByteArrayInputStream(os.toByteArray());
    } catch (RecordStoreException ex) {
        ex.printStackTrace();
        cleanup(r);
        cleanup(e);
        throw new IOException(ex.toString());
    }
}