Reputation: 13108
I would like to know the difference between the following:
FileChannel fc = FileChannel.open();
RandomAccessFile ra = new RandomAccessFile("RandomFile", "rw");
Since Java 7 the class FileChannel
implements SeekableByteChannel
therefore has all it needs in order to randomly access the file.
Can we say that the 2 are totally the same?
Upvotes: 3
Views: 1009
Reputation: 135992
FileChannel
has many more features since it is also GatheringByteChannel
, InterruptibleChannel
, ScatteringByteChannel
. Besides it can lock files, transfer files, work with direct byte buffers, see API
Upvotes: 1