?? myrandomfile.java
字號(hào):
package randomFile;
import java.io.*;
public class MyRandomFile {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動(dòng)生成方法存根
try
{
RandomAccessFile randomfile1=new RandomAccessFile("./two.dat","rw");
//file length
System.out.println("文件長(zhǎng)度"+randomfile1.length());
System.out.println("文件指針"+randomfile1.getFilePointer());
//將文件指針后依5個(gè)字節(jié)
randomfile1.skipBytes(5);
//文件指針
System.out.println("文件指針"+randomfile1.getFilePointer());
// 寫一個(gè)字節(jié)
randomfile1.write(65);
System.out.println("文件長(zhǎng)度"+randomfile1.length());
System.out.println("file pointer"+randomfile1.getFilePointer());
//close file
randomfile1.close();
}
catch(FileNotFoundException e)
{
System.out.println(e);
System.exit(-1);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -