?? iodemo7.java
字號:
import java.io.*;
public class IODemo7{
public static void main(String arg[]){
String s=new String();
float f=3.145f;
try{
RandomAccessFile rwFile1=new RandomAccessFile(
"d:\\javacode\\rwtest.dat","rw");
rwFile1.writeFloat(3.14f);
rwFile1.writeFloat(4.14f);
rwFile1.writeFloat(5.14f);
rwFile1.writeFloat(10.14f);
rwFile1.writeFloat(9.14f);
rwFile1.close();
RandomAccessFile rFile1=new RandomAccessFile(
"d:\\javacode\\rwtest.dat","r");
System.out.println("the first time when written");
for (int i=0;i<5;i++)
System.out.println("Value"+i+":"+rFile1.readFloat());
rFile1.close();
RandomAccessFile rwFile2=new RandomAccessFile(
"d:\\javacode\\rwtest.dat","rw");
rwFile2.seek(8);
System.out.println("pos1="+rwFile2.getFilePointer());
rwFile2.writeFloat(0f);
System.out.println("pos2="+rwFile2.getFilePointer());
rwFile2.close();
RandomAccessFile rFile2=new RandomAccessFile(
"d:\\javacode\\rwtest.dat","r");
System.out.println("the second time when written");
for (int i=0;i<5;i++)
System.out.println("Value"+i+":"+rFile2.readFloat());
System.out.println("pos3="+rFile2.getFilePointer());
System.out.println("length="+rFile2.length());
rFile2.close();
}catch (Exception e){}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -