• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

File Permissions

 
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question was asked three years ago, and the answer was "you can't do that." I'm wondering if this has changed. Here's the question:
You can do setReadOnly() on a java.io.File object, but there's no analogous setReadWrite(). In fact, there seems to be no way to control the permissions or attributes of a File object.
So, has anybody figured out a workaround? How platform-specific is it? I'm trying to do something on OS/400, and so it will be a little different than anything else, although it will probably most closely resemble some sort of ISO Unix technique.
Joe
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it still can't be done in pure Java. If you are sure of the platform, you can use Runtime.exec(). But that's as platform specific as you can get.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Runtime.exec() is probably still the only really good way to do this. What you might do is set up a .properties file contiaining the command/commands to set the permissions. Then, when you move to a different platform, you simply change the .properties file.
Not the most elegant solution, but it would mean that you don't have to re-compile code.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic