how to get the file and folder information in java?
I'm doing a project that has a module as "File or folder information". It means, I need all open files and open directory details.
E.g.:
If one file "aa.txt" was open by user, and the file is in开发者_开发知识库 "bb directory"; the output should be like
aa.txt that file be in open bb dir be in open
and also, if you change that file, the message appear by that module as aa.txt that file has been modified by this user.
You won't be able to do that in pure java, you'll need to use a custom library (depending on the OS) as file/user/permissions information is hidden form Java to make it portable. You can only check if you can read or write to a file using standard java (you have few more methods as isDirectory, but not much more).
Please have a look at Java's java.io.File API. You will get most of the things there.
For checking if the file has been modified, you can use lastModified()
method.
JDK 7 is giving a new The WatchService API and File Change Notification API
. You can read about it here.
精彩评论