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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.