ObjectInputStreamTest.java 598 B

12345678910111213141516171819202122
  1. package course;
  2. import java.io.FileInputStream;
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. /**
  6. * @author WanJl
  7. * @version 1.0
  8. * @title ObjectInputStreamTest
  9. * @description
  10. * @create 2026/8/8
  11. */
  12. public class ObjectInputStreamTest {
  13. public static void main(String[] args) throws IOException, ClassNotFoundException {
  14. //创建反序列化对象
  15. ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:/studentObject.txt"));
  16. //调用方法进行反序列化
  17. Object o = ois.readObject();
  18. System.out.println(o);
  19. }
  20. }