Java doesn't have the concept of user/group/others, as UNIX does. There are some rudimentary methods you can call in the java.io.File class to get some information about the current user's effective permissions on a file, but that's about it.
You can run ls -l, or any other command, using the java.lang.Runtime.exec() family of methods.
You call Runtime.exec(), and you get a java.lang.Process. You call getInputStream() on the Process, and you get a java.io.InputStream. You can then read the process's output from this InputStream. The Process also gives you a stream to read standard error, and a stream that you can write to to provide input for the process.
Wel, I got a lot of things working with it, but for some reason, it refuses to get the information from files or directories with a space in between.
The following command : ls -l "/some/dir/AC Seven Yearmix 2004.mp3" would provide me hte proper info, as the quotes take care of the spaces. If I try to implement this in the Runtime.exec() I get nothing. Runtime.getRuntime().exec( "ls -l \"/some/dir/AC Seven Yearmix 2004.mp3\"" ).getImputStream();
gives an empty string after reading all its bytes. Reason: for some unknown reason, the exec method considers Seven, Yearmix etc as other arguments and as such the command of course cannot find the file
if there some way to escape a space or to replace it with some ascii character to make sure it is preserved as one string?
edit: found it. if I do a myFile.getName().replace(' ', (char) Character.DIRECTIONALITY_WHITESPACE)
it is fixed [ October 28, 2005: Message edited by: Dieter Merlin ]