📄 readcountryinfo.java
字号:
//********************************************************************
// ReadCountryInfo.java Author: Lewis/Loftus
//
// Demonstrates object deserialization.
//********************************************************************
import java.io.*;
public class ReadCountryInfo
{
//-----------------------------------------------------------------
// Reads objects from a serialized file and prints them.
//-----------------------------------------------------------------
public static void main (String[] args) throws Exception
{
FileInputStream file = new FileInputStream ("countries.dat");
ObjectInputStream inStream = new ObjectInputStream (file);
CountryInfo[] countries = new CountryInfo[5];
int scan;
// Deserialize the objects
for (scan = 0; scan < countries.length; scan++)
countries[scan] = (CountryInfo) inStream.readObject();
// Print the objects
for (scan = 0; scan < countries.length; scan++)
System.out.println (countries[scan]);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -