android完全支持ObjectOutputStream
比如我在这个帖子里的示例代码:byte[] bytes = null;
OutputStream out = null;
...
ObjectOutputStream objOutput = new ObjectOutputStream(out);
objOutput.writeShort((short)bytes.length);
比如我在这个帖子里的示例代码:byte[] bytes = null;
OutputStream out = null;
...
ObjectOutputStream objOutput = new ObjectOutputStream(out);
objOutput.writeShort((short)bytes.length);
解决方案 »
- 关于EditText如何获取焦点
- android 4.0以上使用VideoView 播放视频
- 在静态布局动态添加编辑框
- android 基站定位问题
- Android中Thread类的问题
- 大家帮小菜我解决一个问题 急 急 急!!
- 分享个当连续建相同的控件的时候的方法,顺便讨教下一些问题。。。
- 请教,哪位大神做过IKM ANDROID APPLICATION PROGRAMMING
- ScrollView动态插入Layout后,如何清空ScrollView里的内容,求大神!!!
- eclipse中较新版本的adt中的layout editor是不是只有一种视图模式了
- ListView嵌套问题
- android 4.4 设置应用为默认短信的问题
private String name;
private int age;
public void writeToOutputStream(ObjectOutputStream output) throws IOException {
output.writeUTF(name);
output.writeInt(age);
}
public void readFromInputStream(ObjectInputStream input) throws IOException {
name = input.readUTF();
age = input.readInt();
}
}
public static void writeUserListToOutputStream(List<User> users, ObjectOutputStream output) throws IOException {
output.writeInt(users.size());
for (User user : users) {
user.writeToOutputStream(output);
}
}
public static List<User> readUserListFromInputStream(ObjectInputStream input) throws IOException {
List<User> users = new LinkedList<User>();
int count = input.readInt();
for (int i = 0; i < count; i++) {
User user = new User();
user.readFromInputStream(input);
users.add(user);
}
return users;
}