filereader.java
来自「JAVA 工作指南 可以说是程序员必备的东西哦」· Java 代码 · 共 31 行
JAVA
31 行
import java.io.*;public class FileReader { public static void main(String[] args) { try { long dataPosition = 0; int data = 0; RandomAccessFile raf = new RandomAccessFile("datafile", "r"); //Get the position of the data to read. dataPosition = raf.readLong(); //Go to that position. raf.seek(dataPosition); //Read the data. data = raf.readInt(); raf.close(); //Tell the world. System.out.println("The data is: " + data); } catch (FileNotFoundException e) { System.err.println("This shouldn't happen: " + e); } catch (IOException e) { System.err.println("Writing error: " + e); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?