What file sytems support Java UserDefinedFileAttributeView?

落花浮王杯 提交于 2019-12-05 02:50:36

I have tested that custom attributes are supported by following file systems via UserDefinedFileAttributeView: NTFS, Ext4, ZFS. Other popular file systems may support them also. No support was found within following file systems FAT32, HFS+.

I found relying on some list not enough personally. There is always a way to ask the underlying implementation, what views are supported and also whether any concrete view is supported. Check out following code:

final FileSystem defaultFS = FileSystems.getDefault();

for (String fileAttributeView : defaultFS.supportedFileAttributeViews()) {
    System.out.println("Default file system supports: " + fileAttributeView);
}

With an output:

Default file system supports: acl
Default file system supports: basic
Default file system supports: owner
Default file system supports: user
Default file system supports: dos

You can read more in my post on File attributes in NIO.2

I have not found any comprehensive list of all supported file systems. Looks like many modern file systems (ntfs, ext*) are supported. The only way to correctly use these user defined properties is to call supportsFileAttributeView before reading and writing your data.

You might also try Preferences API it stores data in some JVM-managed storage, so technically you don't create any files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!