Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我实现了一个多文件收集器输入流,它能够从以前分散的文件段中读取和组合数据。但是,当前版本使用 RandomAccessFile 和固定大小的 ExecutorService,并且 CPU 开销很大。我想避免这些 I/O 线程并执行基于单线程选择器的方法。不幸的是,FileChannel(或 JDK7 的 Path.newByteChannel())是不可选的。有没有办法以 NIO 的方式收集数据?
看jdk7的AsynchronousFileChannel。
很晚的答案,但为什么它必须是可选的?它具有分散读取和聚集写入,并且文件始终准备好进行读取和写入。那么为什么是可选的呢?