finaris
asked on
Java File properties canRead, canWrite, canExecute
Hi Experts,
for checking file attributes read/write/execute, I currently use
java.io.File.canRead()
java.io.File.canWrite()
java.io.File.canExecute()
In some cases, these functions do NOT return expected results on Windows:
1) canWrite() is TRUE for files on a CD/DVD drive
2) canWrite() is TRUE for files that i cannot access due to missing privileges
3) canWrite() is FALSE for files that do not exist
...
Is a better API/library available to solve all this, or will I have to implement native OS-specific code for this issue?
I already tried the Apache VFS library, which does not return expected results either.
for checking file attributes read/write/execute, I currently use
java.io.File.canRead()
java.io.File.canWrite()
java.io.File.canExecute()
In some cases, these functions do NOT return expected results on Windows:
1) canWrite() is TRUE for files on a CD/DVD drive
2) canWrite() is TRUE for files that i cannot access due to missing privileges
3) canWrite() is FALSE for files that do not exist
...
Is a better API/library available to solve all this, or will I have to implement native OS-specific code for this issue?
I already tried the Apache VFS library, which does not return expected results either.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
works as expected, thanks
Remark:
>> 3) canWrite() is FALSE for files that do not exist
Seems correct to me. (You cannot write to an unexisting file)
Documentation about canWrite():