如何在Java中获取文件和文件夹信息? [英] how to get the file and folder information in java?

查看:58
本文介绍了如何在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.

例如:

如果用户打开了一个文件"aa.txt",并且该文件位于"bb目录"中;输出应该像

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

,此外,如果您更改该文件,则该模块将以 aa.txt的形式显示该用户修改过该文件的消息.

and also, if you change that file, the message appear by that module as aa.txt that file has been modified by this user.

推荐答案

请查看Java的

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 提供了新的 WatchService API和文件更改通知API .您可以在 此处 中阅读.

JDK 7 is giving a new The WatchService API and File Change Notification API. You can read about it here.

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

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