复习笔记13 字符流与字节流

1 标准输入输出流&转换流&打印流

1.1 标准输入输出流

public static final InputStream in:标准输入流 ,用来读取键盘录入的数据

public static final PrintStream out:标准输出流,将数据输出到命令行

1.2 转换流

OutputStreamWriter(OutputStream out) :转换流,把字节输出流转换成字符输出流

InputStreamReader(InputStream in) :转换流,把字节输入流转换成字符输入流

1.3 打印流

打印流添加输出数据的功能,使它们能够方便地打印各种数据值表示形式.

字符打印流 PrintWriter

void print(String str): 输出任意类型的数据,

void println(String str): 输出任意类型的数据,自动写入换行操作

可以自动换行,println()

不能输出字节,但是可以输出其他任意类型

通过某些配置,可以实现自动刷新(只有在调用 printlnprintf  format才有用)

也是包装流,不具备写出功能

可以把字节输出流转换成字符输出流

注意:只能输出不能输入

2 操作流对象

猜你喜欢

转载自www.cnblogs.com/xqd23127/p/10118707.html