InputStream,BuffreredInputStream,InputStreamReader和BufferedReader之间是什么关系? [英] What is the relation between InputStream, BuffreredInputStream, InputStreamReader and BufferedReader?

查看:220
本文介绍了InputStream,BuffreredInputStream,InputStreamReader和BufferedReader之间是什么关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是很困惑何时处理输入数据,如何处理。我在不同的时间找到了不同的解决方案。我也不清楚他们的层次结构。

I always get confused when to process my input data how, which process. Different times i find different solutions. I am also not clear about their Hierarchy.

推荐答案



InputStream是所有输入的父类流和读者。具有Stream关键字的类将与字节一起使用,而具有Reader关键字的类将与字符一起使用。


缓冲区包装在这些流周围,以减少系统调用并提高性能和读取速度。

非缓冲流每次返回单个字节,而缓冲流直到缓冲区变满才返回。

例如,如果您使用BufferedReader,则可以使用 readLine(),但在非缓冲流中,您必须使用 read()方法读取单个字符。



InputStream is parent class of all input streams and readers. Classes that have Stream keyword will work with bytes whereas classes which have Reader keyword will work with characters.

Buffer is wrapper around these streams to decrease the system calls and increase performance and speed of reading.

Non buffered streams return single byte each time whereas Bufferd stream will not return until the buffer gets full.

For example if you take BufferedReader you can read a whole line using readLine() but in non buffered stream you must read single character using read() method.

这篇关于InputStream,BuffreredInputStream,InputStreamReader和BufferedReader之间是什么关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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