Home | Blog | Java | Jokes | Poems | Musings | Site Map | Kudos | Downloads | Useful Sites | Interesting | System Setup | Contact

Home Page

AKGBackup - The backup program

            

 

Section 11 : The java.io Package


Describe the permanent effects on the file system of constructing and using FileInputStream, FileOutputStream, and RandomAccessFile objects.


 

FileInputStream

 

Creating an object of this class does not have any effect on the file system. When you try to use the object for reading the file it represents, it opens the file for reading if the file exists. Attempts to use this object may throw FileNotFoundException if the file does not exist, is a directory or for some other reason cannot be opened for reading.

 

FileOutputStream

 

Creating an object of this class opens the file it represents, to write to the file. If the file does not exist, a new file is created for writing. Attempts to use this object may throw FileNotFoundException if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason.

 

RandomAccessFile

 

The mode argument in its constructor must either be equal to “r” or “rw”, indicating that the file is to be opened for input only or for both input and output, respectively. The write methods on this object will always throw an IOException if the file is opened with a mode of “r”. If the mode is “rw” and the file does not exist,  then an attempt is made to create it. An IOException is thrown if the file argument refers to a directory. These constructors will throw IllegalArgumentException if mode is not “r” or “rw”. If file exists but is a directory, or cannot be opened or created for any other reason.

 


section11-1 | section11-2 | section11-3 | section11-4 | section11-5 | section11-6

Sections : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11

 

 

 

 

 

 

 

Home | Blog | Java | Jokes | Poems | Musings | Site Map | Kudos | Downloads | Useful Sites | Interesting | System Setup | Contact  

Loading

 Number of Pages viewed on this site since January' 2003 : Hit Counter eXTReMe Tracker

For any queries, comments or suggestions, write to me .

This site never compromises your privacy, please read this site's privacy policy.