2013-04-23 16 views
1

当我将新的UserDefinedFileAttributeView属性添加到文件时,Java存储此信息的位置在哪里? 目录中没有其他文件,当我查看文件属性时,该文件没有任何新的属性或详细信息。Java UserDefinedFileAttributeView

我的代码:

String versionAttrName = "report.version"; 
try {   
    Path path = FileSystems.getDefault().getPath(filePath, ""); 
    UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class); 
    view.write(versionAttrName, Charset.defaultCharset().encode(newVersion)); 
} catch (IOException e) { 
    System.out.println("7 - Error saving version to file! - "+ filePath + " - " + e.getMessage()); 
} 
+0

你检查你的用户目录和'programdata'目录......我建议做一个硬盘搜索,会找到文件的最快方法: ) – 2013-04-23 14:46:54

+0

想要搜索什么?哈哈,我不知道Java会使用什么文件名/类型 – gwin003 2013-04-23 14:52:19

回答

2

这些元数据使用文件系统的 “扩展文件属性”(见wikipedia)存储。

我找不到任何全面支持的文件系统列表(绝对是JVM特有的),因此您应该在您计划支持的所有平台上进行测试。但this答案列出了一些和this提到了一些关于Linux的细节。希望这可以帮助。

0

这取决于您正在运行的平台。

按照OpenJDK的文档:The details of such emulation are highly implementation specific and therefore not specified.

在Windows然而测试表明它使用NTFS备用数据流:

PS C:\test> Get-Item -Path C:\test\asdf.txt -stream * 


    FileName: C:\test\asdf.txt 

Stream     Length 
------     ------ 
:$DATA      0 
myaltstream    1337 

在Linux上使用扩展属性。

不知道别人 - 希望这有助于:)