public long transferTo(final long position, final long count, FileChannel target) throws IOException { if (allAreSet(state, READ_SHUTDOWN) || count <= 0L) { return 0L; } target = thread.getWorker().getXnio().unwrapFileChannel(target); long res; if (Native.HAS_SPLICE && target instanceof FileChannelImpl) { res = Native.testAndThrowWrite(Native.spliceToFile(fd, target, position, count)); if (Native.EXTRA_TRACE) log.tracef("Splice(%d -> %s): %d", fd, target, res); } else { res = target.transferFrom(new ConduitReadableByteChannel(this), position, count); } if (res == 0) state &= ~READ_READY; checkReadTimeout(res > 0); return res; }