1
private Map<String, List<DrawPath>> savedPath= new LinkedHashMap<String, List<DrawPath>>();

I want to write this "savedPath" to file, but throw a 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

It works successfully if changed to Map<String, String>, is it relevant with my custom DrawPath class? How can I write this object to file success? Thanks

4

1 回答 1

1

确保您写入文件的所有对象都是可序列化的,保存 Paint 可能是问题所在

于 2013-08-18T16:24:54.623 回答