Two Laptop Bag*
The moose likes I/O and Streams and the fly likes File.setReadOnly() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File.setReadOnly()" Watch "File.setReadOnly()" New topic


Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
There is method 'boolean setReadOnly()' in class. With this i can make the file read-only. But there is no way to remove the read-only attribute. There are no methods like unsetReadOnly() or setReadWrite(). Any ideas how to do this?

Joy is a radiation
feng chou

Joined: Oct 15, 2002
Posts: 8
public class test{
public static void main(String[] args)
throws IOException{
int c;
BufferedInputStream i=
new BufferedInputStream(
new FileInputStream("readOnlyFile");
BufferedOutputStream o=
new BufferedOutputStream(
new FileOutputStream(
}//you can try these codes.
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
This code may work. But it may not solve my problem. I've asked whether there are any programmatic ways to unset a readOnly flag which is set using the setReadOnly() method of class..
Consider Paul's rocket mass heater.
subject: File.setReadOnly()
Similar Threads
Lock symbol in jbuilder 2005 foundation?
I cannot delete a file.
true or false......implicit obj's threadsafe?
New to WL8.1
why config is read only???