Author Topic:   I/O Package
Betty Reynolds
ranch hand
posted April 18, 2000 01:27 AM         
One of the objectives of the exam for the I/O section is:

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

I really don't see any permanent effect on the file system from using FileInputStream, but I think what this is getting at is what physical impact do these classes have on the file system.

This information is not easy to dig out of the API, so I've been doing it by trial and error. As far as I can see there are only four ways to create a file using the java.io package (not including the myriad of ways that you can wrap the underlying FileOutputStream and FileWriter).

They are:


  • with FileOutputSream;
  • with FileWriter;
  • using the createNewFile method from the File class
  • using RandomAcessFile.

Is this correct? Is there anything else that I've overlooked?

maha anna
bartender
posted April 18, 2000 01:51 PM             
Betty,
What you listed makes the complete list of classes which makes a permanent effect on the file system as far as I could check and think of . How I think is what can make a permanent effect on the file system ? Generally readers are soft. They don't modify the file/file contents. They just try to read ,if at all the SecurityManager gives permission to go ahead. Otherwise, the operations done using a FileInpuStream throws either FileNotFoundException or IOException or SecurityException. So this eliminates the possibility of all the reading related classes. This readuces a lot of head-ache.

Now ,we have left with all the writing related classes. Even in this we can do some elimination. If you take any HighLevel Output Streams /Writers which operate on other OutPutstreams/Writers only, they also don't touch the underlying file system either. They operate on other outputsteams/Writers.So we can easily eliminate all DataInputStream/BufferedInputsteram.... like that ,all simillar high level classes which take ONLY another samelevel/lowlevel OutputStream/Writer classes as arguments to their construction.

Now we have left with all the low-level OutputStreams/Writers. These ones really touch the underlying fileSystem (hard-disk/floppy-disk etc. ) We have to really check them. As you checked, 1. File 2.FileOutputStream 3.FileWriter 4.RandomAccessFile only take file/filedescripter/String filename and creates them if it already not exists. Note also that RandomAccessFile uses (String,"r"/"rw") (File ,"r"/"rw") as arguments.

Also we can easily eliminate all other Interfaces like DataInput/DataOutput/ObjectInput/ObjectOutput etc. They are not at all realted to making a permanent effect on the local file system. Does this sound good?

regds
maha anna

[This message has been edited by maha anna (edited April 18, 2000).]

Betty Reynolds
ranch hand
posted April 18, 2000 02:02 PM         
Excellent maha anna.

Betty Reynolds
ranch hand
posted April 18, 2000 04:39 PM         
By the way, I originally got the URL for the Sun site that has the objectives for the I/O package from a post that Marcus Green did to his discussion board a few weeks back.

The URL for the exam objectives that is listed at alot of sites, is an older or different one that does not include the I/O objectives.

Its a good idea to keep an eye on his board. He is always throwing out useful tidbits of information like this.

maha anna
bartender
posted April 18, 2000 04:54 PM             
Yes Betty. I agree. Do you remember? He is the first person who posted this information to JavaRanch Java Cert Discussion here. See here.

regds
maha anna

[This message has been edited by maha anna (edited April 18, 2000).]

|