Inserting text in middle using RandomAccessFile removes some text after that

前端 未结 5 2079
攒了一身酷
攒了一身酷 2020-12-12 02:20

My Sample Code

    String line = null;
    RandomAccessFile file = new RandomAccessFile(\"D:/mahtew.txt\", \"rw\");
    System.out.println(file.getFilePointe         


        
5条回答
  •  情歌与酒
    2020-12-12 02:44

    RandomAccessFile

    A random access file behaves like a large array of bytes stored in the file system.

    In fact it does not care about shifting the array elements in the case of write operations (only the pointer is advanced). Such an operation overwrites existing values:

    Output operations write bytes starting at the file pointer and advance the file pointer past the bytes written.

提交回复
热议问题