This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: RandomAccessFile -  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: RandomAccessFile -  "rw", "rwd"" Watch "NX: RandomAccessFile -  "rw", "rwd"" New topic
Author

NX: RandomAccessFile - "rw", "rwd"

Terry Martinson
Ranch Hand

Joined: Oct 18, 2003
Posts: 293
I use the RandomAccessFile approach for io. I currently open the raf with mode "rwd". Here is the API info I find for the different modes:

"rw" Open for reading and writing. If the file does not already exist then an attempt will be made to create it.
"rws" Open for reading and writing, as with "rw", and also require that every update to the file's content or metadata be written synchronously to the underlying storage device.
"rwd" Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.

I have not worked a lot with RandomAccessFile and am wondering if one is suggested over the others. I did notice in the API description for the "rws" and "rwd" it mentions they may be more efficient.
Thoughts?
TJ


SCJP, SCJD, SCWCD, SCBCD
Jason Mowat
Ranch Hand

Joined: Aug 17, 2003
Posts: 79
I had one issue with RW and RandomAccessFile:

Aside from that issue, I found RW to be quite sufficient.
Cheers,
Jason
Jacques Bosch
Ranch Hand

Joined: Dec 18, 2003
Posts: 319
Yes, good point.
I put the file.exist check in my launch dialog. It has to exist before the server will launch.


Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: NX: RandomAccessFile - "rw", "rwd"
 
Similar Threads
RandomAccessFile
Using Random access file to write to a file with long absolute path take long time in unix
NX: What RandomAccessFile mode to use?
File opeing modes
RandomAccessFile in 1.4.2