• 请不要在回答技术问题时复制粘贴 AI 生成的内容
codeant
V2EX  ›  程序员

Java nio 包里 isRegularFile

  •  
  •   codeant · May 27, 2020 · 2728 views
    This topic created in 2184 days ago, the information mentioned may be changed or developed.

    最近在看 nio 的文章,看到有个 isRegularFile 这个方法没理解什么意思,源码的注释是 Tests whether a file is a regular file with opaque content.,什么是正常的不透明的文件呢?有大神讲解下么

    4 replies    2020-05-27 12:59:01 +08:00
    nziming
        1
    nziming  
       May 27, 2020
    !isSymbolicLink() && !isDirectory() && !isOther();
    fixend
        2
    fixend  
       May 27, 2020
    regular file 一般都是 linux/unix 下面的说法,windows 编程的书没看到这个。
    比如 linux 下面,设备也是一个文件,这个就不属于 regular file,还有就是楼上说的那些。
    反正 regular file 就是一个普通文件。
    kilen3a
        3
    kilen3a  
       May 27, 2020
    是不是还有 isDirectoryFile isBlockSpecialFile isSymbolicLinkFile 什么的,那都是 Unix 系的文件分类法 bcdpsl 什么的
    Mutoo
        4
    Mutoo  
       May 27, 2020
    在 *nix 系统中,万物皆文件,文件夹、设备、网络、流等等都是文件。

    后半句 opaque content 的意思是,这个接口不读取文件的实际内容来判断它是否为普通文件(而是通过 directory 或操作系统操作的信息)。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5533 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 03:07 · PVG 11:07 · LAX 20:07 · JFK 23:07
    ♥ Do have faith in what you're doing.