java io

java io继承关系图:

inputStream vs Reader

http://stackoverflow.com/questions/4367539/what-is-the-difference-between-reader-and-inputstream
An InputStream is the raw method of getting information from a resource. It grabs the data byte by byte without performing any kind of translation. If you are reading image data, or any binary file, this is the stream to use.
A Reader is designed for character streams. If the information you are reading is all text, then the Reader will take care of the character decoding for you and give you unicode characters from the raw input stream. If you are reading any type of text, this is the stream to use.
You can wrap an InputStream and turn it into a Reader by using the InputStreamReader class.
Reader reader = new InputStreamReader(inputStream);

solution:

如果是读取字符类文件,可以使用Reader和Writer,不用担心编码问题。
如果是读取二进制文件,图片等等可以使用InputStream和OutputStream。


本站总访问量次,本站访客数人次,本文总阅读量