2021-09-08 IO流(读取转换流)
作者:
Denholm | 来源:发表于
2021-09-25 20:09 被阅读0次
![](https://img.haomeiwen.com/i15903080/1e30a9be9228a363.png)
clipboard.png
![](https://img.haomeiwen.com/i15903080/bfd3dc37dcee69c2.png)
clipboard.png
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class TransStreamDemo {
public static void main(String[] args) throws IOException {
InputStream in = System.in;
// 将字节流对象转换为字符流对象,使用转换流,InputStreamReader
InputStreamReader isr = new InputStreamReader(in);
// 为了提高效率,将字符串进行缓冲区技术高效操作,使用BufferedReader
BufferedReader bufr = new BufferedReader(isr);
String line;
while ((line = bufr.readLine()) != null) {
if ("over".equals(line)) {
break;
}
System.out.println(line.toUpperCase());
}
bufr.close();
}
}
本文标题:2021-09-08 IO流(读取转换流)
本文链接:https://www.haomeiwen.com/subject/abdbwltx.html
网友评论