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());
}
}
Aggregations