package com.qing.qing.test;
import com.qing.qing.entity.CertBdcInfo;
import org.apache.commons.io.FileUtils;
import java.io.*;
import java.text.ParseException;
public class Test {
public static void main(String[] args) throws ParseException {
try {
CertBdcInfo bdcInfo = null;
//序列化 实体类需实现序列化接口java.io.Serializable
bdcInfo = new CertBdcInfo();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(bdcInfo);
FileUtils.writeByteArrayToFile(new File("D:\ytzz\copy\bdcInfo"),byteArrayOutputStream.toByteArray());
//反序列化
byte[] byteArray = FileUtils.readFileToByteArray(new File("D:\ytzz\copy\bdcInfo"));
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(byteArray));
bdcInfo = (CertBdcInfo) in.readObject();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}