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

📄 binaryinputdemo.java

📁 java编程代码
💻 JAVA
字号:

import java.io.ObjectInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.FileNotFoundException;

public class BinaryInputDemo
{
  public static void main(String[] args)
  {
     try
     {
         ObjectInputStream inputStream = 
           new ObjectInputStream(new FileInputStream("numbers.dat"));

         System.out.println("Reading the file numbers.dat.");
         int n1 = inputStream.readInt( );
         int n2 = inputStream.readInt( );

         System.out.println("Numbers read from file:");
         System.out.println(n1);
         System.out.println(n2);
         inputStream.close( );
     }
     catch(FileNotFoundException e)
     {
         System.out.println("Cannot find file numbers.dat.");
     }
     catch(IOException e)
     {
         System.out.println("Problems with input from numbers.dat.");
     }
     System.out.println("End of program.");
  }
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -