您的位置 首页 java

java的字节流与字符流

java的I/O接口提供两种传输数据的数据格式:基于字节操作的接口(InputStream和OutputStream)、基于字符操作的接口(Writer和Reader)。

I/O操作最小的存储单元都是字节,也就是说数据持久化及网络传输都是以字节进行的,而不是字符。那么为什么JDK要提供基于字符操作的Writer和Reader的接口呢?原因在于我们在编程过程中通常操作的数据都是字符形式,为了方便操作于是有了直接操作字符的接口,如此而已。(字节与字符的相互转换可以简单理解为byte[]与String的相互转换)

字符到字节需要经过 编码 转换,非常耗时,而且未设置好编码的情况下容易出现乱码。

文章来源:智云一二三科技

文章标题:java的字节流与字符流

文章地址:https://www.zhihuclub.com/183848.shtml

关于作者: 智云科技

热门文章

评论已关闭

4条评论

  1. Groups for each outcome measure were then analyzed by one way ANOVA followed by Tukey s multiple comparison posttest where the ANOVA P value was 0

  2. Effect of cinnamon, cardamom, saffron and ginger consumption on blood pressure and a marker of endothelial function in patients with type 2 diabetes mellitus A randomized controlled clinical trial

  3. Published data on the oncologic outcomes of cystectomies are limited, and these studies have included a small number of patients

网站地图