Checking file permissions for a specified user account in Java
I'm running a Java application as a Windows Service and am using another Java application, which is executed by another user, to set a directory used by the Wi开发者_Python百科ndows Service application.
Is there a way in Java to determine the file permissions of a directory for another user? In my case, I want to know the file permissions of the Windows Service application while running a separate Java application executed by another user.
This kind of filesystem support is not available in standard Java, because Java is cross-platform and filesystem security differs greatly across platforms (or may not exist at all). However, there are plans to add this support to Java 7 (which we have been waiting for years to get!)
If you are only using it on Windows and you know C/C++, you can use a JNI (Java Native Interface) like JNA to tap into the Windows DLLs and get this information. Otherwise, you can get a trial or a paid version of JNIWrapper which works out-of-the-box. I'm not sure if it provides support for file security, but it does provide other filesystem support - you'll need to review the feature list.
精彩评论