标签:java 序列化 serializable
可以将java对象序列化为文件,也可以将文件反序列化为java对象
地址:分享java的Serializable功能 代码:http://www.zuidaima.com/share/1550463266802688.htm
package com.zuidaima.util.file; import java.io.FileOutputStream; import java.io.ObjectOutputStream; /** * 序列化java对象到文件 * * @author www.zuidaima.com * */ public class SerializeObject2File { public static void main(String args[]) { serializeAddress("www.zuidaima.com", "zuidaima"); } public static void serializeAddress(String street, String country) { Address address = new Address(); address.setStreet(street); address.setCountry(country); try { FileOutputStream fout = new FileOutputStream("c:\\zuidaima_com.ser"); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(address); oos.close(); System.out.println("Done"); } catch (Exception ex) { ex.printStackTrace(); } } }
标签: java 序列化 Serializable话题: 语言基础 脚本和工具
分享java的Serializable功能,布布扣,bubuko.com
标签:java 序列化 serializable
原文地址:http://blog.csdn.net/yaerfeng/article/details/37901863