This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:Using RandomAccessFile and FileChannel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:Using RandomAccessFile and FileChannel" Watch "NX:Using RandomAccessFile and FileChannel" New topic
Author

NX:Using RandomAccessFile and FileChannel

Bill Robertson
Ranch Hand

Joined: Mar 21, 2003
Posts: 234
I am using RandomAccessFile to read my DB file. I noticed is some other
posts people using RandomAccessFile to read the header and then retrieving
a FileChannel to read in the data.
What is the advantage of the FileChannel? Can't you just use RandomAccessFile for reading the entire file?
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello Bill,
There is no requirement in the assignment dictating the choice of RAF v/s filechannels. As a matter of fact, you can do the whole IO using "old" style Random Access Files all-together (that is what I did). The NIO (new IO) package/capability introduced in jdk 1.4 + has improved the IO speed and allowed for bi-directional read/write channels etc. I am staying away from it until I finish the entire assignment and then may be work on introducing file-channels (the keywords being "may be"). It depends on what you can get more comfortable with in a reasonable amount of time.
Regards.
Bharat


SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX:Using RandomAccessFile and FileChannel
 
Similar Threads
NX: FileChannel & ThreadSafety
Using RandomAccessFile on huge file
NX: (Contractors) File I/O class
FileChannel and read method
what is the most optimized way of writing a file