【发布时间】:2013-05-04 02:59:17
【问题描述】:
FileChannel.open(path) 方法返回什么样的FileChannel 对象?
是否仍然允许随机访问,好像如下所示?
RandomAccessFile ra = new RandomAccessFile("RandomIndeed","rw");
FileChannel fc1 = ra.getChannel();
fc1和下面的实例fc有什么区别:
FileChannel fc = FileChannel.open(path);
基本上我想知道上面创建的两个对象之间有什么区别,因此fc1 和fc
提前致谢。
【问题讨论】:
-
两个调用都返回相同的对象 (sun.nio.ch.FileChannelImpl)(至少对于 Unix 文件系统)。