gpt4 book ai didi

Java:随机访问文件模式 "rws"与 "rwd"?

转载 作者:搜寻专家 更新时间:2023-10-30 21:05:56 26 4
gpt4 key购买 nike

RandomAccessFile constructor接受指定文件打开方式的 mode 字符串。

我对 "rws""rwd" 模式之间的区别感到困惑。

这是 docs 的内容状态:

"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.

"rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.

[...]

The "rwd" mode can be used to reduce the number of I/O operations performed. Using "rwd" only requires updates to the file's content to be written to storage; using "rws" requires updates to both the file's content and its metadata to be written, which generally requires at least one more low-level I/O operation.

...并且没有解释metadata 的含义。这是否意味着 "rws" 更新了文件系统上的last modified timestamp,而 "rwd" 没有?

最佳答案

Does it mean that "rws" updates the last modified timestamp on the filesystem, and "rwd" doesn't ?

rws 刷新文件的内容和文件的修改日期。

rwd 刷新文件的内容,但在文件关闭之前修改日期可能不会更改。

rw 仅在您告诉它时刷新,并且在您关闭文件之前不会更改修改日期。

顺便说一句,rwd 的写入速度比 rw 慢得多,而 rws 又慢了一些。

关于Java:随机访问文件模式 "rws"与 "rwd"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14232539/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com