Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to reset a file or a directory property  RSS feed

 
Eideo Guo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi All
i want to read a file and write it,but the file is readonly,how i can set the file can be wrote

thank
eideo
[ October 25, 2005: Message edited by: Eideo Guo ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, you can't do this with pure Java. Your best bet is probably to use the exec() method in Runtime to execute a command to do this. Of course this will only work if the Java process is started from an account that has the necessary permissions to change the permissions. I.e. if the file is read-only, and you don't own the file, the system is probably not going to let you change the permissions. The whole purpose of permissions is to prevent you from doing this sort of thing.

If you do use the exec() approach, you will probably benefit from studying this article.
 
Eideo Guo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!