0
當我試圖保存Image上傳的用戶時,出現以下錯誤。java.io.IOException:不支持對象類型
java.io.IOException: Object type not supported: com.codename1.ui.Image value: [email protected]
at com.codename1.io.Util.writeObject(Util.java:406)
以下是我的程序。
用戶類
public class User implements Externalizable {
private String name;
private Image proImg;
public void externalize(DataOutputStream out) throws IOException {
Util.writeUTF(getName(), out);
Util.writeObject(getProImg(), out);
}
public void internalize(int version, DataInputStream in) throws IOException {
setName(Util.readUTF(in));
setProImg((Image) Util.readObject(in));
}
...
}
的StateMachine類
protected void onCreateAccountGui_SaveBtnAction(Component c, ActionEvent event) {
User usr = new User();
usr.setName(findNametxta(c).getText());
usr.setProImg(findProImgGallery(c).getImage());
try
{
storedUser.writeObject("userStore", usr);
}
catch(Exception e)
{
e.printStackTrace();
}
}