📄 serialwritetest.java
字号:
/**
* @(#)SerialWriteTest.java
*
*
* @author
* @version 1.00 2007/11/17
*/
import java.io.*;
import java.util.*;
class Address implements Serializable {
protected String first,email;
public Address() {
first=email="";
}
public Address(String _first,String _email) {
first=_first;
email=_email;
}
public String toString() {
return first+" ("+email+")";
}
}
public class SerialWriteTest {
/**
* Creates a new instance of <code>SerialWriteTest</code>.
*/
public SerialWriteTest() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
try{
ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream("4.txt"));
int i=10;
Date now=new Date();
Address address=new Address("fuzhou","fuzhou@x.y");
out.writeInt(i);
out.writeObject(now);
out.writeObject(address);
out.close();
}
catch (IOException ioe) {
System.out.println(ioe);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -