File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO question

 
Cristian Negresco
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Cristian Negresco
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic