Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting file attributes in Java

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?

like image 519
user1144342 Avatar asked Jul 13 '26 05:07

user1144342


1 Answers

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.

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.

like image 161
Chuck Adams Avatar answered Jul 15 '26 19:07

Chuck Adams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!