IO流,随机访问流RandomAccessFile的概述和读写数据。
RandomAccessFile类不属于流,是Object类的子类,但它融合了InputStream和OutputStream的功能,支持对随机访问文件的读取和写入。
public static void main(String[] args) throws IOException{
RandomAccessFile raf = new RandomAccessFile("g.txt","rw");
raf.write(97);
int x = raf.read();
raf.seed(0); //设置写入指针的位置,从哪里开始写入
raf.close();
}
添加微信进交流群: opiopi293