datafileexample.java
来自「java版的数据结构的完全代码 免费提供了 学习数据结构的请下载」· Java 代码 · 共 27 行
JAVA
27 行
// Introduced in Chapter 17import java.io.*;/** Example of storing data in binary format. */public class DataFileExample { /** * If an int is provided on the command line, store it in * number.data. Otherwise, read an int from number.data * and print it. */ public static void main(String[] args) throws IOException { File file = new File("number.data"); if (args.length > 0) { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file)); out.writeInt(Integer.parseInt(args[0])); out.close(); } else { ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); System.out.println(in.readInt()); } } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?