获取Java中文件的最后修改用户和创建者用户 [英] Get last modified user of a file and creator user in Java
问题描述
我知道我们可以使用File.lastModified()获取文件的lastModified日期,但是我不确定是否有办法获取修改文件和创建文件的用户名?
I know that we can get lastModified date for a file using File.lastModified() but I am not sure if there is a way i can get the username who modified the file and who created the file?
因为我们有一个服务器,团队中的每个人都可以访问.因此,我们正计划构建一个程序,为我们提供一个创建文件和上次修改文件的用户名列表.
Because we have a server that everyone in the team has access. So we are planning to build a program that gives us a list of usernames who created the file and who modified the file last time.
这是在Windows操作系统上.
This is on Windows OS.
推荐答案
您可以使用java.nio类获得大量其他File属性,尤其是 PosixFileAttributeView .
You can get a whole lot of additional File attributes with the java.nio classes, especially the Files
utility class which has Files.getOwner()
or can retrieve a PosixFileAttributeView.
请注意,我认为大多数文件系统仅具有所有者的概念,而没有创建者/最后的修饰符.
Note that I think most filesystems have only the notion of a owner, not a creator/last modifier.
这篇关于获取Java中文件的最后修改用户和创建者用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!