如何將對(duì)象序列化為字符串我能夠?qū)⒁粋€(gè)對(duì)象序列化為一個(gè)文件然后再次恢復(fù)它,如下一個(gè)代碼片段所示。我想將對(duì)象序列化為字符串并存儲(chǔ)到數(shù)據(jù)庫(kù)中。誰能幫我?LinkedList<Diff_match_patch.Patch> patches = // whatever...FileOutputStream fileStream = new FileOutputStream("foo.ser");ObjectOutputStream os = new ObjectOutputStream(fileStream);os.writeObject(patches1);os.close();FileInputStream fileInputStream = new FileInputStream("foo.ser");ObjectInputStream oInputStream = new ObjectInputStream(fileInputStream);Object one = oInputStream.readObject();LinkedList<Diff_match_patch.Patch> patches3 = (LinkedList<Diff_match_patch.Patch>) one;os.close();
如何將對(duì)象序列化為字符串
ibeautiful
2019-08-24 15:46:41