如果找到了对您有用的资料,烦请点击右手边的Google广告支持我继续共享知识,谢谢! http://dengpeng.spaces.live.com/

2008年5月5日星期一

Implements Serializable() in J2ME

Serializable is avaliable in J2SE and J2EE only.

However, you can do it manually. To do that you just need to write each value individually into a radiogram or a byte stream...

radiogram.reset();
radiogram.writeInt(1000); // integer
radiogram.writeUTF("hello"); // string


then when you get the radiogram or stream on the host decode it in the exact same order



int number = radiogram.readInt(); // integer
String text = radiogram.readUTF(); // string


so if you have an object that you wnat to serialise you could just add a method to encode to radiogram, and likewsie decode...


没有评论: