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

解决方案 »

  1.   

    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. 
      

  2.   

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

  3.   

    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. rwd 可以被用来降低I/O操作执行的数量。它只要求更新文件内容被写入存储。
    RWS要求更新文件内容和Metadata(元数据)(它是“关于数据的数据”(data about data))
    被写入。一般要求至少一次以上的低层I/O操作。
    大概就这意思。
      

  4.   

    mode 参数指定用以打开文件的访问模式。允许的值及其含意为: 值  含意
     
    "r"   以只读方式打开。调用结果对象的任何 write 方法都将导致抛出 IOException。  
    "rw"  打开以便读取和写入。如果该文件尚不存在,则尝试创建该文件。  
    "rws" 打开以便读取和写入,对于 "rw",还要求对文件的内容或元数据的每个更新都同步写入到基础存储设备。  
    "rwd"   打开以便读取和写入,对于 "rw",还要求对文件内容的每个更新都同步写入到基础存储设备。  
      

  5.   

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