⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readcountryinfo.java

📁 java源程序 对初学者有很大的帮助 从简单到复杂
💻 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 + -