private Map<String, List<DrawPath>> savedPath= new LinkedHashMap<String, List<DrawPath>>();
我想将此“savedPath”写入文件,但抛出 IOException:
public static class DrawPath implements Serializable{
/**
*
*/
public static final long serialVersionUID = 1L;
public Path path;
public Paint paint;
}
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(sdFile));
out.writeObject(savedPath); // throws IOExcption
改成Map<String, String>
就成功了, 它与我的自定义 DrawPath 类相关吗?如何将此对象写入文件成功?谢谢
最佳答案
确保您写入文件的所有对象都是可序列化的,保存 Paint 可能是问题所在
关于android - 如何在 Android 中将自定义对象写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18301141/