码迷,mamicode.com
首页 > 编程语言 > 详细

java里头几个重要的IO概念

时间:2014-11-11 11:01:56      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   java   sp   for   on   ad   ef   

同步与异步

阻塞还是不阻塞,轮询还是事件驱动

Netty是事件驱动的

Buffer and Stream

Java has two kinds of classes for input and output (I/O): streams and readers/writers.

Streams (InputStream, OutputStream and everything that extends these) are for reading and writing binary data from files, the network, or whatever other device.

Readers and writers are for reading and writing text (characters). They are a layer on top of streams, that converts binary data (bytes) to characters and back, using a character encoding.

Reading data from disk byte-by-byte is very inefficient. One way to speed it up is to use a buffer: instead of reading one byte at a time, you read a few thousand bytes at once, and put them in a buffer, in memory. Then you can look at the bytes in the buffer one by one.

Channel and Stream

Channel与Stream的区别在于:Channel是双向的,而Stream只能是单向的

Channel是以一个chunk一个chunk为单位读写的,但是stream说白了还是依赖一个byte一个byte的buffer

As previously mentioned, original I/O deals with data in streams, whereas NIO deals with data in blocks.

java里头几个重要的IO概念

标签:io   ar   os   java   sp   for   on   ad   ef   

原文地址:http://my.oschina.net/zuoyc/blog/342946

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!