import java.io.File;
import java.io.RandomAccessFile;
public class RandomAccessFileDemo01{
public static void main(String args[])throws Exception{
File f = new File("i:"+File.separator+"code"+File.separator+"java"+File.separator+"RandomAccess.txt");
RandomAccessFile raf = new RandomAccessFile(f,"rw");
String name = "zhangsan";
int age = 20;
raf.writeBytes(name);
raf.writeInt(age);
name = "wangwu";
age = 21;
raf.writeBytes(name);
raf.writeInt(age);
raf.close();
}
}
————————————————————————————
写入后的文件内容为数字是乱码,两个很奇怪的符号
|