正如我发现的,底层操作系统调用 is copyToFile(),Libcore.os.read(fd, bytes, byteOffset, byteCount)whiletransferTo()基于内存映射文件:
MemoryBlock.mmap(fd, alignment, size + offset, mapMode);
...
buffer = map(MapMode.READ_ONLY, position, count);
return target.write(buffer);
Run Code Online (Sandbox Code Playgroud)
Q1:我的发现是对还是错?
Q2:有什么理由使用FileUtils.copyFile()asFileChannel.transferTo()似乎应该更有效吗?
谢谢