更新时间:2023-02-23 21:49:39
你实现它如下:
RandomAccessFile
RandomAccessFile
RandomAccessFile
RandomAccessFile
将位置记录为距文件开头的字节偏移量,并使用相同的值进行搜索。
Record the position as a byte offset from the start of the file, and use the same value for seeking.
您可以修改上述内容以重复使用 RandomAccessFile
对象,而不是每次都打开/关闭它。
You can modify the above to reuse the RandomAccessFile
object rather than opening / closing it each time.
UPDATE - RandomAccessFile
的javadoc是这里。寻找 seek
和 getFilePointer
方法。
UPDATE - The javadocs for RandomAccessFile
are here. Look for the seek
and getFilePointer
methods.