inserting data in the middle of a text file throug

2020-02-12 16:40发布

I want to insert the data at some positions in the text file without actually overwriting on the existing data.I tried RandomAccessFile ....but that also overwrites it.... Is there any way to insert the data without overwriting?? -Thanks in advance

2条回答
冷血范
2楼-- · 2020-02-12 17:23

It is not possible (not with Java, and not with any other programming language) to "just" insert data in the middle of the file, without having to re-write the rest of the file. The problem is not the programming language, the problem is the way files work.

查看更多
Bombasti
3楼-- · 2020-02-12 17:28

You have to read your file and rewrite it. During this operation you have to find the place where you want to put your text and write it.

查看更多
登录 后发表回答