Inserting text in middle using RandomAccessFile removes some text after that

前端 未结 5 2078
攒了一身酷
攒了一身酷 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:46

    If replaced string is too long, the strings after the line matched with input will be replaced. It seems you have to read file, modify it and write back to old or new file. Of course, you have options to use multi-threading programming and Java 7's new IO features to improve performance.

提交回复
热议问题