Reader/Writer与InputStream/OutputStream的区别

1. Readers and writers are like input streams and output streams. The primary difference lies in the
fundamental datatype that is read or written; streams are byte-oriented, whereas readers and
writers use characters and strings.

2. The reason for this is internationalization. Readers and writers were designed to allow programs
to use a localized character set and still have a stream-like model for communicating with
external devices.

3. These are analogous to the read( ) methods defined for InputStream. For example, read( )
still returns an integer. The difference is that, instead of data values being in the range of 0-255
(i.e., single bytes), the return value is in the range of 0-65535 (appropriate for characters, which
are 2 bytes wide).

4. Instead, readers and writers can be used as a layer on top of streams™ most readers have a
constructor that takes an InputStream as an argument, and most writers have a constructor
that takes an OutputStream as an argument.

1.主要区别在于被读和被写入的基本数据类型;InputStream OutputStream 是面向字节的,Reader Writer 使用的字符和字符串。

2.国际化:Reader Writer允许的程序使用本地化的字符集,仍然有流的特性。

3.Reader定义上类似InputStream的。例如,Reader还是返回一个整数。所不同的是,代替数据值在0-255的范围内(即单字节),返回值是在0-65535之间(适合字符,2个字节宽)。

4.大多数Reader 有一个构造函数的InputStream作为参数,并且大多数Writer 有一个构造函数这需要一个OutputStream作为参数。

转载于:https://my.oschina.net/u/2349605/blog/414565

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值