2013-08-18 17 views
1
private Map<String, List<DrawPath>> savedPath= new LinkedHashMap<String, List<DrawPath>>(); 

我想寫這個「savedPath」到文件到文件,而是拋出一個IOException異常:如果換成Map<String, String>如何編寫自定義對象的Android

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 

它的工作原理成功,是它相關的有我的自定義DrawPath類?我怎樣才能寫這個對象文件成功?謝謝

+0

請發佈您的Logcat錯誤日誌以及您的問題。 –

+0

它通過try catch { \t \t \t \t \t out.writeObject(savedPath); \t \t \t \t}趕上(IOException的發送){ \t \t \t \t \t // TODO自動生成的catch程序塊 \t \t \t \t \t e.printStackTrace(); \t \t \t \t} – user2694203

+0

嗯,控制檯選項卡附近有一個logcat選項卡。當應用程序崩潰時,您發現的錯誤會打印在那裏。請在應用崩潰時查找logcat中的所有錯誤代碼和字符串,並將其粘貼到您的問題中。 –

回答

1

請確保您寫入文件的所有對象都是可序列化的,保存畫圖可能是問題

+0

我應該如何保存Paint?或者除了DrawPath類以外Serializable的其他對象?非常感謝! – user2694203

相關問題