package com.lovecoding.day22.io03;

import org.junit.Test;

import java.io.*;

public class TestObject {

    @Test
    public void test03(){
        try(
                ObjectInputStream ois = new ObjectInputStream(new FileInputStream("emp.dat"));
        ) {

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test02() throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("emp.dat"));

        Employee o = (Employee) ois.readObject();

        System.out.println(o);

        ois.close();

    }

    //序列化
    @Test
    public void test01() throws IOException {
        Employee e1 = new Employee("zs",22,"北京");

        //对象流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("emp.dat"));
        //写对象
        oos.writeObject(e1);

        oos.close();


    }


}
