- Java code
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(); }}
是这样的乱码: 3 p X @ #(
------解决方案--------------------------------------------------------
long 是8个字节,chart是一个字节吧