File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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..
I agree. Here's the link:
subject: File.setReadOnly()
It's not a secret anymore!