问题
I need to store custom data with a file in file system (about 50 bytes with each file). I do not have any other storage to keep the data and can not create an extra file for this. These are my requirements I can not change it.
I have found that this can be done using UserDefinedFileAttributeView class.
What file systems support this feature? NTFS, FAT, any other file systems on Linux?
Where the data is actually stored and how reliable is it?
回答1:
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+.
回答2:
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
回答3:
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.
来源:https://stackoverflow.com/questions/15319586/what-file-sytems-support-java-userdefinedfileattributeview