📄 filereader.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -