[問題]到底serialization是?

看板java作者 (嗯..一切隨他去吧.)時間19年前 (2006/06/01 17:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
不好意思 我看下來還是不太理解 由於我在寫network program 有用到ObjectOutputStream 裡面就牽涉到Serializable的問題 在q大給的網頁中(http://0rz.net/1b1s0) 一開始寫著 A Bean persists by having its properties, fields, and state information saved and restored to and from storage. The mechanism that makes persistence possible is called serialization. 所以Serializable是指 Object在作存取時的一種機制嗎? ex:ObjectOutputStream的writeObject 以下是api中ObjectOutputStream的一段文字 The default serialization mechanism for an object writes the class of the object,the class signature, and the values of all non-transient and non-static fields. 就是說除了 加上transient關鍵字 以及 static field以外的東西都會被輸出到串流裡面 請問一下是這個意思嗎? 同樣在ObjectOutputStream的api網頁中寫到 Only objects that support the java.io.Serializable interface can be written to streams. 那這樣它的範例 FileOutputStream fos = new FileOutputStream("t.tmp"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeInt(12345); oos.writeObject("Today"); oos.writeObject(new Date()); oos.close(); 中的 Integer, String Date 其實都是有 implement serializable了? 以上是我的幾個問題 麻煩各位了 感恩<(_ _)> -- 中文書是什麼..可以吃嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.134.40.163
文章代碼(AID): #14VhYsNf (java)
文章代碼(AID): #14VhYsNf (java)