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.
当您想将一个流复制到另一个流时,NIO 的通道是否比 IO 的输入流/输出流更快?如果不是,你什么时候会使用渠道?
对于大多数用途来说,这并不重要。如果您使用 NIO 直接缓冲区来复制数据,则可以节省一两个内存副本并获得可衡量的改进,但是我建议您做您认为最简单的事情,并且在 Java 中它可能足够快。即,您应该达到网络或磁盘子系统的限制。
我将从 IOUtils.copy(in, out); 开始 看看这是否足够快。