InputStream vs InputStreamReader

前端 未结 6 1460
暗喜
暗喜 2020-12-12 14:43

What\'s the benefit of using InputStream over InputStreamReader, or vice versa.

Here is an example of InputStream in action:

6条回答
  •  情书的邮戳
    2020-12-12 15:36

    If you want to read binary data use InputStream.

    If you want to read strings from a binary stream, use InputStreamReader. One of its constructors allows you to specify a character set.

    For this reason do not use FileReader as it uses a platform default for a character set, which is, in many cases, not practical.

提交回复
热议问题