transferFromを使用して、NIOを使用していくつかの小さなファイルからファイルを組み立てようとしています。
transferFrom の呼び出しは 0 を返します。例外はありません。同期動作をオンにするために何も行われません。
FileOutputStream fos = new FileOutputStream(path);
FileChannel fileBeingAssembled = fos.channel();
int progressiveOffset = 4096;
FileInputStream fis = new FileInputStream(tmpT5);
FileChannel channel = fis.getChannel();
channel.position(0);
int thisItemLength = (int)channel.size();
LOG.info("Writing " + tag + " at " + progressiveOffset + " length " + thisItemLength);
fileBeingAssembled.position(progressiveOffset);
long x = fileBeingAssembled.transferFrom(channel, progressiveOffset, thisItemLength);
LOG.info("transferred " + x);
progressiveOffset += thisItemLength;
ログの例:
4409 [main] INFO com.basistech.seg.writing.ModelOutputTask - available 1856216
4409 [main] INFO com.basistech.seg.writing.ModelOutputTask - Writing word at 15024620 length 1856216
4419 [main] INFO com.basistech.seg.writing.ModelOutputTask - transferred 0