permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on RandomAccessFile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on RandomAccessFile" Watch "Question on RandomAccessFile" New topic
Author

Question on RandomAccessFile

Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
In R&H it is given that
"Constructing an instance of RandomAccessFile is like constructing an instance of File :No file is created on the file system."
But the following code creates ab.txt .

How?Is R&H wrong?
Veena


SCJP1.4
"Continuous effort - not strength or intelligence - is the key to unlocking our potential."
*Winston Churchill
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
From the API:

So it does look there is some discrepancy here.
Could be that there is no file until the stream get s (maybe) written to, flushed, and closed.
What's R&H?
-Barry
[ August 12, 2002: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Veena Pointi
Ranch Hand

Joined: Jun 20, 2002
Posts: 442
R&H is short name for the book Java2 Certification Study Guide by Simon Roberts & Philip Heller
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Sorry don't have it.
zarina mohammad
Ranch Hand

Joined: Jun 26, 2002
Posts: 104
In R&H it is given that
"Constructing an instance of RandomAccessFile is like constructing an instance of File :No file is created on the file system."

veena,
another point to note in R&H is that RandomAccessFile creates a file if does not exist only if the instance is created in the "rw" mode. if you run the same code in "r", it throws a FileNotFound exception

-zarina
biju joseph
Greenhorn

Joined: Aug 02, 2002
Posts: 7
Is there IO for certification exam 1.4?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
No, the 1.4 exam does not include AWT or IO.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787

In R&H it is given that
"Constructing an instance of RandomAccessFile is like constructing an instance of File :No file is created on the file system."

Hi Veena, Zarina:
Is it possible that R&H is making the point that
no phyiscal file will be created on file system
immediately after the instance of RandomAccessfile
is created. But as soon as you start writing to
this file, the file will appear at file system level...
Thanks
Barkat
[ August 12, 2002: Message edited by: Barkat Mardhani ]
[ August 12, 2002: Message edited by: Barkat Mardhani ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on RandomAccessFile