Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

change the file permission mode  RSS feed

 
xiaorui chen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Could someone help me?
In a Java application, I would like to change a file permision from readable to writtable , then in later part of the application, I want to change it back to readable. How can I make these changes in Java application.
I though about using the policy file before, but once the policy is used, you cannot change and use different policy file in a single application.
What is the good solution for changing the file permission mode?
Thanks for any comment.
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use the policy file, you have to ensure the setSecurityManager and createSecurityManager permissions are granted. Then when you need to access the file you create the permissions needed, and when your done, again set the manager back. This only controls permissions for java applications using that policy file. If you're trying to prevent other applications and users from changing the file, try using Runtime exec() to execute chmod or attrib based on the system your on.
Hope this helps
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!