0

我有 2 个问题

  1. 如果我的操作系统不支持 AIO(低于 linux 2.6 等),AsynchronousFileChannel 将如何工作。

  2. 如何将 sth 附加到 AsynchronousFileChannel,据我所知 AsynchronousFileChannel 只支持 write(ByteBuffer, long position, A attachment, CompletionHandler handler) 和 write(ByteBuffer src, long position) 都需要一个位置参数。我应该自己计算位置吗?

4

1 回答 1

1

问题 2:来自javadoc

异步文件通道在文件中没有当前位置。相反,文件位置被指定给每个启动异步操作的读写方法。

所以是的,您需要自己跟踪位置。

于 2015-07-08T07:39:29.967 回答