Search in sources :

Example 6 with RecordStore

use of javax.microedition.rms.RecordStore in project CodenameOne by codenameone.

the class GameCanvasImplementation method createStorageOutputStream.

/**
 * @inheritDoc
 */
public OutputStream createStorageOutputStream(String name) throws IOException {
    RecordStore r = null;
    RMSOutputStream os = null;
    DataOutputStream out = null;
    try {
        Short key = (Short) fat.get(name);
        if (key == null) {
            // need to add a key to the FAT
            key = new Short(currentKey);
            fat.put(name, key);
            r = RecordStore.openRecordStore("FAT", true);
            byte[] data = toRecord(name, currentKey);
            currentKey++;
            r.addRecord(data, 0, data.length);
            r.closeRecordStore();
            r = null;
        }
        os = new RMSOutputStream(key.shortValue());
        return os;
    } catch (Exception err) {
        cleanup(r);
        cleanup(os);
        cleanup(out);
        throw new IOException(err.getMessage());
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) RecordStore(javax.microedition.rms.RecordStore) IOException(java.io.IOException) RecordStoreException(javax.microedition.rms.RecordStoreException) MediaException(javax.microedition.media.MediaException) IOException(java.io.IOException) ConnectionNotFoundException(javax.microedition.io.ConnectionNotFoundException)

Aggregations

IOException (java.io.IOException)6 ConnectionNotFoundException (javax.microedition.io.ConnectionNotFoundException)6 MediaException (javax.microedition.media.MediaException)6 RecordStore (javax.microedition.rms.RecordStore)6 RecordStoreException (javax.microedition.rms.RecordStoreException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 DataInputStream (java.io.DataInputStream)4 RecordEnumeration (javax.microedition.rms.RecordEnumeration)4 DataOutputStream (java.io.DataOutputStream)2 Enumeration (java.util.Enumeration)2 Vector (java.util.Vector)2 ActionEvent (com.codename1.ui.events.ActionEvent)1 ActionListener (com.codename1.ui.events.ActionListener)1 Hashtable (java.util.Hashtable)1 ApplicationPermissions (net.rim.device.api.applicationcontrol.ApplicationPermissions)1 ApplicationPermissionsManager (net.rim.device.api.applicationcontrol.ApplicationPermissionsManager)1