日期:2014-05-20 浏览次数:20712 次
import java.io.*; public class TestRandomAccessFile { public static void main(String args[]) throws Exception{ RandomAccessFile raf=new RandomAccessFile("C:\\Documents and Settings\\Administrator\\桌面\\raf.txt","rw"); for(int i=0;i<10;i++){ raf.writeLong(i*1000); } raf.seek(5*8); raf.writeLong(13256); raf.seek(0); for(int i=0;i<10;i++){ System.out.println(i+"="+raf.readLong()); } raf.close(); } }