rw,rwd,rws是什么

来源:互联网 发布:虚拟商城软件下载 编辑:程序博客网 时间:2024/05/16 18:48

在进行如下代码操作时:

RandomAccessFile randomFile = new RandomAccessFile(fileName, "rw");

rw是什么意思呢,其实很简单,我将rw改了一下,然后就会报错RandomAccessFile randomFile = new RandomAccessFile(fileName, "额w");

RandomAccessFile randomFile = new RandomAccessFile(fileName, "额w");

弱弱的解释下;其实就是reading writing device synchronously(同步)

Value

Meaning

"r"Open for reading only. Invoking any of the write methods of the resulting object will cause an IOException to be thrown."rw"Open for reading and writing. If the file does not already exist then an attempt will be made to create it."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.
原创粉丝点击