In Java, byte = 8 bit, char = 16 bit

In C/C++, char = 8 bit

There is difference because Java uses Unicode, however C uses ASCII as basic character collection.

Java uses InputStream to read BYTE-DATA, to cover InputStream with InputStreamReader to read CHAR-DATA, to cover InputStreamReader with BufferedStream to read line of chars. So java have to recomprehend the byte infomation into char information and into line-chars information with a 2-step conversion.

Rembember the following:

size:   8 bit -> 16 bit -> line -> file

mode: byte -> char -> line -> file

read:  IS -> ISR -> BR -> String

write: OS -> OSW ->( *BW ->) PW -> String

Why do we have the parenthesized BW part?, see the official doc:(Java SE 8)

In general, a Writer sends its output immediately to the underlying character or byte stream. Unless prompt output is required, it is advisable to wrap a BufferedWriter around any Writer whose write() operations may be costly, such as FileWriters and OutputStreamWriters. For example,

 PrintWriter out
= new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));

will buffer the PrintWriter's output to the file. Without buffering, each invocation of a print() method would cause characters to be converted into bytes that would then be written immediately to the file, which can be very inefficient.

When reviewing some test programs that I wrote following the java tutorial, find something like:

 FileOutputStream out = new FileOutputStream("1.txt");
//Considering using the following method instead
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("1.txt"));

Checked Java SE 8 official API, that BOS method exists! Gee.. And, that's the exact usage of BOS.. Gee again...

Java R&W Related的更多相关文章

  1. python3 文件操作练习 r+ w+ a+ 的理解

    突然来一句:“慨然有经略四方之志” 文件操作三部曲:1.先用open打开 2.再写关闭  3.再回到中间写操作     为啥要刚打开就关闭 那是很容易望,所以先写上... 基本格式 f = open( ...

  2. SmartSql = Dapper + MyBatis + Cache(Memory | Redis) + ZooKeeper + R/W Splitting + ......

    SmartSql Why 拥抱 跨平台 DotNet Core,是时候了. 高性能.高生产力,超轻量级的ORM.156kb (Dapper:168kb) So SmartSql TargetFrame ...

  3. fopen特殊模式r+, w+, a+辨析

    fopen模式分两大类,即 TEXT模式:r, w, a, r+, w+, a+ BIN模式:rb, wb, ab, r+b, w+b, a+b 模式 读指针初始位置 写指针初始位置 模式用途 详细说 ...

  4. python r r+ w w+ rb 文件打开模式的区别

    # 只读模式with open ( "file.txt" ,'r' ) as f:        for line in f.readlines():                ...

  5. C语言中文件打开模式(r/w/a/r+/w+/a+/rb/wb/ab/rb+/wb+/ab+)浅析

    C语言文件打开模式浅析 在C语言的文件操作语法中,打开文件文件有以下12种模式,如下图: 打开模式  只可以读   只可以写  读写兼备 文本模式 r w a r+ w+ a+ 二进制模式 rb wb ...

  6. 008PHP文件处理——文件操作r w (用的比较多) a x(用的比较少) 模式 rewind 指针归位:

    <?php /** *文件操作r w (用的比较多) a x(用的比较少) 模式 rewind 指针归位: */ /*$a=fopen('a.txt','r'); echo fread($a,f ...

  7. 第九天- 文件操作 r w a 文件复制/修改

    文件操作简介:使用python来读写文件是非常简单的操作.我们使用 open() 函数来打开一个文件,获取到文件句柄.然后通过文件句柄就可以进行各种各样的操作了.根据打开⽅方式的不同能够执行的操作也会 ...

  8. python文件读写模式 --- r,w,a,r+,w+,a+,rb,wb

    要了解文件读写模式,需要了解几种模式的区别,以及对应指针 r : 读取文件,若文件不存在则会报错 w: 写入文件,若文件不存在则会先创建再写入,会覆盖原文件 a : 写入文件,若文件不存在则会先创建再 ...

  9. 转发:i p _ f o r w a r d函数

    转发:i p _ f o r w a r d函数到达非最终目的地系统的分组需要被转发.只有当 i p f o r w a r d i n g非零或当分组中包含源路由时,i p i n t r才调用实现 ...

随机推荐

  1. Java 泛型 通配符类型

    Java 泛型 通配符类型 @author ixenos 摘要:限定通配符类型.无限定通配符类型.与普通泛型区别.通配符捕获 通配符类型 通配符的子类型限定(?都是儿孙) <? extends ...

  2. jquery收集--php收集所有post数据

    $model = D('Account'); $data = $model->create(); jquery收集数据  sendinvite.serialize() function init ...

  3. JS学习之路,菜鸟总结的注意事项及错误更正

    JavaScript 是一种面向对象的动态语言,它的语法来源于 Java 和 C,所以这两种语言的许多语法特性同样适 用于 JavaScript.需要注意的一个主要区别是 JavaScript 不支持 ...

  4. Redis持久存储-AOF&RDB

    Redis中数据存储模式有2种:cache-only,persistence;cache-only即只做为"缓存"服务,不持久数据,数据在服务终止后将消失,此模式下也将不存在&qu ...

  5. Chapter 15_0 模块和包

    通常,Lua不会设置规则,相反会提供很多强有力的机制来使开发者有能力实现出最适应的规则. 然而,这种方法对于模块就不行了.模块系统的一个主要目标是允许以不同的形式来共享代码. 但若没有一项公共的规则就 ...

  6. javascript焦点图之缓冲滚动无缝切换

    在用于实现无缝切换四张图,所以设置了6个图片就是 4,0,1,2,3,4,0 <!DOCTYPE html> <html> <head> <meta char ...

  7. PowerDesigner 的mysql PDM 的COMMENT注释

    PowerDesigner 的mysql PDM 的COMMENT注释 2012-11-01 15:38 4447人阅读 评论(0) 举报 分类: 数据库相关(7) PowerDesigner 的my ...

  8. yali项目的slider

    // 调用 var s41 = new slider({ target : '#slider411', titleActiveClass : 'j-active', itemActiveClass : ...

  9. <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    1.X-UA-Compatible X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中使用 ...

  10. COM与.NET程序集导出和部署COM组件

    为了分布式和多客户端调用我们还需要将写好的COM组件发布到一台服务器上.这里我们将组件部署到操作系统的COM+应用程序中去.如果没此需要就可以导出后,在C++环境中调用COM了. 第一步:导出COM组 ...