File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File.setReadOnly()" Watch "File.setReadOnly()" New topic
Author

File.setReadOnly()

Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
Hi!
There is method 'boolean setReadOnly()' in java.io.File 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
Greenhorn

Joined: Oct 15, 2002
Posts: 8
import java.io.*;
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(
"canWriteFile");
while((c=i.read())!=-1)
o.write(c);
in.close();
out.close();
}
}//you can try these codes.
Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
Hi!
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 java.io.File class..
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File.setReadOnly()