• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

File.canWrite()?

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3060
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic