我想了解以下内容的区别: FileChannel fc = FileChannel.open(); RandomAccessFile ra = new RandomAccessFile("RandomFile", "rw"); 自Java 7以来,类FileChannel实现了SeekableByteChannel,因此具有随机访问文件所需的所有功能。我们可以说这两者完全相同吗?
FileChannel 有更多的功能,因为它也是 GatheringByteChannel、InterruptibleChannel 和 ScatteringByteChannel。此外,它还可以锁定文件、传输文件、使用直接字节缓冲区,详见 API。