readObject
/writeObject
functions himself (in J2SE it is optional).
Also class should have public default constructor (constructor without parameters) or
should have no constructor at all.
ObjectOutputStream
serialize sequence of objects into the array of bytes.
And ObjectInputStream
can be used to extract objects packed in byte array.
It is possible to use these classes to exchange objects through the net (in this case SerME
should be used on both sides).
Currently there are two implementation of IStorage interface - RmsStorage, based on javax.miroedition.rms package and FileStorage based on javax.miroedition.io.file package. First alternative is available at all J2ME compatible environments. Each object is stored as separate record in RecordStore. Also metadata (names of the classes of persistent objects) is stored. The main disadvantage of this solution is thjat RMS implementation is very inefficient and its size is very restricted.
Second alternative is supported only by most advanced mobiles devices (such as smartphones and PDA). It provides much better performance.
ObjectOutputStream
and ObjectInputStream
classes are not needed, and visa verse - if you are using SerME only for serialization, then
org.garret.serme.rms package can be skipped). There is also yet another simple hint of decreasing
code size - use obfuscator. Obfucator replaces identifiers written by programmer with generated ones,
which are usually significantly smaller. Such simple thing can reduce size of .jar file up to 10%.
If it is not enough, you can also leave support only of those types which are used in your application.
Look for new version at my homepage | E-Mail me about bugs and problems