I recently came across FileChannel, I am a big fan of RandomAccessFile. But I am wondering why would I pick FileChannel
over RandomAccessFile
for reading from a file and writing that content to another.
Is there any specific performance reason? I dont want to use locking of FileChannel
for any purpose as I believe that could be one of the reasons why filechannel can be used. I don't want to use BufferReader
or anything like that as suggested in other StackOverflow response.
FileChannel API says: A region of a file may be mapped directly into memory; for large files this is often much more efficient than invoking the usual read or write methods.