public class RadomAccessFileTest {
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users/Administrator/Desktop/a.txt");
RandomAccessFile raf = new RandomAccessFile(file,"rw");
System.out.println(raf.getFilePointer());
raf.seek(raf.length());
raf.write("a");
}
}
RandomAccessFile 一次只能写一个字节,"a"是个字符串,可以换成'a'或者"a".getBytes();
getBytes()方法可以设置编码类型如gbk,utf-8等