1
我嘗試在我的環境中添加對UserDefinedFileAttributeView的支持。這是我迄今爲止所做的。我已經添加了 'user_xattr' 選項/ etc/fstab文件:Java的Filestore類的supportsFileAttributeView(...)
#/was on /dev/sda3 during installation
UUID=9b1809de-d409-47ce-aee0-dd1e878b0bab/ ext4 errors=remount-ro,user_xattr 0 1
# /boot was on /dev/sda2 during installation
UUID=fd898890-17a0-423a-987e-9dc0a5008320 /boot ext2 defaults 0 2
# /home was on /dev/sda5 during installation
UUID=439ea035-cac4-4801-9023-b1b1abb4ab9e /home ext4 defaults,user_xattr 0 2
# swap was on /dev/sda1 during installation
UUID=a534b1c7-1a00-488f-92a8-a530b5d902ac none swap sw 0 0
這樣一個簡單的代碼:
for (FileStore store : fileSystem.getFileStores()) {
boolean supported = store.supportsFileAttributeView(UserDefinedFileAttributeView.class);
System.out.println(store.name() + " --- " + supported);
}
顯示了一個 '/ home'(的/ dev/sdar5)是顯示:
/dev/sda5 --- true
但是,如果我不喜歡這樣寫道:
FileStore store1 = Files.getFileStore((new File("/home")).toPath());
boolean supported1 = store1.supportsFileAttributeView(UserDefinedFileAttributeView.class);
System.out.println(store1.name() + " --- " + supported1);
我得到:
/dev/sda5 --- false
這是爲什麼?我認爲在兩種情況下都是「真實的」。 我的操作系統是Linux Mint 17.2 Rafaela 64位。
您使用的是什麼版本的Java? – VGR
@VGR我使用Java 1.8.0_65 –