java RandomAccessFile 覆盖数据
迷茫
迷茫 2017-04-17 14:22:26
0
1
1124
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
大家讲道理

The answer is no.
RandomAccessFile

This sentence

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

RandomAccessFile treats the file as a byte array. Its behavior of modifying the value of a certain position is to write the value of the i-th position as a new value, and then point the pointer to the next element.

As you can see, this class will not help you complete all the remaining value shifting functions. So if you need to complete the "insert" function, you need to read the subsequent contents of the array yourself and write them to the file in order.

stackoverflow reference:

  1. Inserting text in middle using RandomAccessFile removes some text after that
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!