aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes IO question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IO question" Watch "IO question" New topic
Author

IO question

Cristian Negresco
Ranch Hand

Joined: Sep 15, 2001
Posts: 182
Sorry,
I put this question on IOStreams section but the discussions are not very hot there.
So I came back to my "home base"...;0)
So here it is, again:
In Java2 1.3 and 1.4 I couldn't find any method that make a file writable.
There is a setReadOnly() method but no method that could get me out of this state. It doesn't seem very OO to me.
Did I miss something?

BR,
Cristian
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
I'm not sure I get your question right. A File object is not used to write or read a file on disk. To achieve the latter you should use the FileInputStream/FileOutputStream or FileReader/FileWriter classes. Another class called RandomAccessFile allows you to specify the mode in which you want to open the file, that is, read, read/write, ...
Does this answer your question?


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Cristian Negresco
Ranch Hand

Joined: Sep 15, 2001
Posts: 182
Hello,
What I meant actually was that the File object could be used to change the actual file's properties, to make it read only. That's ok, but the problem is that there is no method to make the file writable again.
Shortly: I expected the File to have a method like: "setBackToWritable()" that will erase the setReadOnly()consequence.
Best Regards,
Cristian
Dan Paun
Greenhorn

Joined: Jul 19, 2002
Posts: 3

Originally posted by Cristian Negresco:
In Java2 1.3 and 1.4 I couldn't find any method that make a file writable.
There is a setReadOnly() method but no method that could get me out of this state. It doesn't seem very OO to me.
Did I miss something?

Try java.io.FilePermission
http://java.sun.com/j2se/1.4.1/docs/api/index.html


Best regards!<br />Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IO question