面向流的IO与面向块的IO [英] Stream oriented IO vs Block Oriented IO

查看:289
本文介绍了面向流的IO与面向块的IO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java具有面向流的IO(java.io. )和面向块的IO(java.nio。)。面向块的IO如何提高IO的性能?

Java has stream oriented IO(java.io.) and Block oriented IO(java.nio.). How does block oriented IO improve the performance of IO?

推荐答案

主要是减少复制的需要。由于面向流的API必须将所有内容移动到托管Java变量中,因此系统必须复制您处理的所有数据。当您使用NIO库时,Java可以直接映射到OS I / O页面而无需复制(并处理分配和垃圾收集)。

Primarily by reducing the need for copying. Since the stream-oriented APIs have to move everything into managed Java variables, the system has to copy all of the data you deal with. When you use the NIO libraries, Java can directly map in the OS I/O pages without having to make copies (and deal with allocation and garbage collection).

这篇关于面向流的IO与面向块的IO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆