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();

}

posted @ 2020-07-02 21:44  一块  阅读(204)  评论(0编辑  收藏  举报