在Java中获取文件属性 [英] Getting file attributes in Java

查看:459
本文介绍了在Java中获取文件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个 java.io.File 代表一个 .exe 文件,我如何发现文件属性 - 例如:创建的大小和日期,以及如何发现可执行属性中的数据 - 例如:文件版本?

Given a java.io.File that represents a .exe file, how can I discover the file attributes - for example: size and date created, and how could I discover the data in the executable properties - for example: file version?

推荐答案

p>大概你在这里指的是NTFS扩展属性,它只是在最近(截至Java SE 7),你已经能够得到这些没有某种Windows特定的JNI黑客。这应该是新的NIO2文件属性界面。这些属性中的一些(如大小)是基本属性,而诸如版本的其他属性则是用户属性。

Presumably you're referring to NTFS Extended Attributes here, and it's only recently (as of Java SE 7) that you've been able to get at these without some kind of windows specific JNI hackery. This should be doable with the new NIO2 file attributes interface. Some of these attributes, such as size, are basic attributes, while others such as version are "user" attributes.

可能是使用这个API的例子的最佳页面是 http://www.ibm.com/developerworks/java/library/j-nio2-2/ - 搜索文件属性if您对其他API的示例不感兴趣。

Probably the best page with examples that explains the use of this API is at http://www.ibm.com/developerworks/java/library/j-nio2-2/ -- search down for "File attributes" if you're not interested in the examples of the other APIs.

这篇关于在Java中获取文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆