is it possible to set custom metadata on files, using Java?

后端 未结 2 1287
陌清茗
陌清茗 2021-02-14 21:46

Is it possible to get and set custom metadata on File instances? I want to use the files that I process through my system as some kind of a very simple database, where every fil

2条回答
  •  抹茶落季
    2021-02-14 22:39

    You should always check if the filesystem supports UserDefinedFileAttributeView for the specific file you want to set You can simply invoke this

    Files.getFileStore(Paths.get(path_to_file))).supportsFileAttributeView(UserDefinedFileAttributeView.class);
    

    From my experience, the UserDefinedFileAttributeView is not supported in FAT* and HFS+ (for MAC) filesystems

提交回复
热议问题