站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2SE 专题RandomAccessFile的构造方法中的参数

RandomAccessFile的构造方法中的参数

摘要: RandomAccessFile的构造方法中的参数


public RandomAccessFile(String name, String mode)

第二个参数,可以为-#34;rws-#34;或-#34;rwd-#34;,请问两者有什么区别?我已经看了JDK文档,还是不明白,希望有人出来解释得清楚一点。



rws-#34; Open for reading and writing, as with -#34;rw-#34;, and also require that every update to the file-#39;s content or metadata be written synchronously to the underlying storage device.
-#34;rwd-#34; Open for reading and writing, as with -#34;rw-#34;, and also require that every update to the file-#39;s content be written synchronously to the underlying storage device


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




关注!



我早就说过,JDK文档我已看过,你复制出来有什么用?不明白这里为什么这么多人喜欢把JDK文档复制出来。



贴子加10分,寻求高手。



up


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

rwd 可以被用来降低I/O操作执行的数量。它只要求更新文件内容被写入存储。
RWS要求更新文件内容和Metadata(元数据)(它是“关于数据的数据”(data about data))
被写入。一般要求至少一次以上的低层I/O操作。


大概就这意思。


mode 参数指定用以打开文件的访问模式。允许的值及其含意为:

值 含意

-#34;r-#34; 以只读方式打开。调用结果对象的任何 write 方法都将导致抛出 IOException。
-#34;rw-#34; 打开以便读取和写入。如果该文件尚不存在,则尝试创建该文件。
-#34;rws-#34; 打开以便读取和写入,对于 -#34;rw-#34;,还要求对文件的内容或元数据的每个更新都同步写入到基础存储设备。
-#34;rwd-#34; 打开以便读取和写入,对于 -#34;rw-#34;,还要求对文件内容的每个更新都同步写入到基础存储设备。



-#34;r-#34; 以只读方式打开。调用结果对象的任何 write 方法都将导致抛出 IOException。
-#34;rw-#34; 打开以便读取和写入。如果该文件尚不存在,则尝试创建该文件。
-#34;rws-#34; 打开以便读取和写入,对于 -#34;rw-#34;,还要求对文件的内容或元数据的每个更新都同步写入到基础存储设备。
-#34;rwd-#34; 打开以便读取和写入,对于 -#34;rw-#34;,还要求对文件内容的每个更新都同步写入到基础存储设备。


中文JDK的解释


↑返回目录
前一篇: 请教 System.out.println("test " + s1=="Java")
后一篇: 大侠,如何获取一个文件使用的字符集(Charset)?