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

📄 iooperation.java

📁 飞机航班的查询系统
💻 JAVA
字号:
package planeInformation;

import java.io.*;

class IOOperation {
	private File file = new File("C:\\info.txt");

	public IOOperation() {
		try {
			if (!file.exists())
				file.createNewFile();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * write to file
	 */
	public void write(Plane[] s) {
		try {
			FileOutputStream fos = new FileOutputStream(file);
			ObjectOutputStream objOut = new ObjectOutputStream(fos);
			objOut.writeObject(s);
			objOut.close();
			fos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * read all student information from file
	 */
	public Plane[] getAllPlane() {
		Plane ss[] = new Plane[100];
		try {
			if (file.length() > 0) {
				FileInputStream fis = new FileInputStream(file);
				ObjectInputStream ois = new ObjectInputStream(fis);
				ss = (Plane[]) ois.readObject();
				ois.close();
				fis.close();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ss;
	}
}

⌨️ 快捷键说明

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