debug8_4.java

来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 35 行

JAVA
35
字号
package questions.c8;
import java.io.*;
public class Debug8_4 {
   private static final String FILE_NAME
      = "debug8_4.ser";
   int count = 11;
   Thread t = new Thread();
   String title = "Placeholder";
   public static void main( String[] args ) {
      try {
         File objectFile = new File( FILE_NAME );
         Debug8_4 x = new Debug8_4();
         x.count = 57;
         x.title = "Varieties";
         FileOutputStream fos =
            new FileOutputStream( objectFile );
         ObjectOutputStream oos =
            new ObjectOutputStream( fos );
         oos.writeObject( x );
         oos.close();
         FileInputStream fis =
            new FileInputStream( objectFile );
         ObjectInputStream ois
            = new ObjectInputStream( fis );
         Debug8_4 retrieved
            = (Debug8_4) ois.readObject();
         ois.close();
         System.out.println( retrieved.count );
         System.out.println( retrieved.title );
      }
      catch ( Exception x ) {
         System.out.println( x );
      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?