main.java
来自「java的经典例子」· Java 代码 · 共 31 行
JAVA
31 行
import java.io.*;
import java.util.Date;
class Main {
public static void main(String[] args) {
try {
// Write 2 instances of Date
FileOutputStream f = new FileOutputStream("Test1.ser");
ObjectOutputStream out = new ObjectOutputStream(f);
Date d = new Date();
out.writeObject(d);
out.writeObject(d);
out.flush();
out.close();
// Write 2 instances of Date, separated by reset()
f = new FileOutputStream("Test2.ser");
out = new ObjectOutputStream(f);
out.writeObject(d);
out.reset();
out.writeObject(d);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?