记录管理系统为何回出现如此情况?
问题:在反序列化时代码出现错误,系统提示为:setpicture(byte[]) in MMSMIDlet.mmsdatabase cannot be applied to(int)
class mmsdatabase {
private String address = " ";//定义成员变量
private String timestamp = " ";
private String text = " ";
private byte[] picture ={};
public mmsdatabase() {
}
public mmsdatabase(String _address, String _timestamp,String _text,byte[] _picture) {
this.address =_address;
this.timestamp =_timestamp;
this.text =_text;
this.picture =_picture;
}
//这里省略了getxxx()方法和setxxx()方法
public void serialize(DataOutputStream dos) throws
IOException {//序列化
dos.writeUTF(address);
dos.writeUTF(timestamp);
dos.writeInt(picture.length);
dos.write(picture);
dos.writeUTF(text);
dos.flush();
}
public static mmsdatabase deserialize(DataInputStream dis) throws IOException {//反序列化
mmsdatabase database = new mmsdatabase();
database.setaddress(dis.readUTF());
database.settimestamp(dis.readUTF());
int length =dis.readInt();
database.picture =new byte[length];
database.setpicture(dis.read(picture));//问题出现在这里,应该如何修改
database.settext(dis.readUTF());
return database;
}
}
------解决方案--------------------public void serialize(DataOutputStream dos) throws IOException {//序列化
dos.writeUTF(address);
dos.writeUTF(timestamp);
dos.writeInt(picture.length);
dos.writeUTF(text);
dos.write(picture);
dos.flush();
}
public static mmsdatabase deserialize(DataInputStream dis) throws IOException {//反序列化
mmsdatabase database = new mmsdatabase();