readcountryinfo.java
来自「java源程序 对初学者有很大的帮助 从简单到复杂」· Java 代码 · 共 32 行
JAVA
32 行
//********************************************************************
// 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 + =
减小字号Ctrl + -
显示快捷键?