• Post Reply Bookmark Topic Watch Topic
  • New Topic

File.canWrite()?  RSS feed

 
eric sato
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
I have a directory name /abc/Foo/allFilesHere that created by user "A" and Foo directory mode is 777 and allFilesHere is 444. By using Unix scripting allows me to delete or modify all the files under "Foo" directory. [except no allow to change mode chmod]
Now the problem i'm facing is by using Java, File.canWrite() [under the "Foo" directory] it return me false. How should i able to delete the file using java while File.canWrite() return me false?
Thanks in advance.
Regards,
sato
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember right, having a directory with 777 permissions that contains a file with 444 permissions sets up a somewhat paradoxical situation in Unix. You can't directly modify the file, because it is read only, but you can delete it and create another with the same name. That's because those are directory operations and you have full permissions on the directory. Your Java application is obliged to follow the same rules that the command-line shell does.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!