import java.io.*; public class Main { public static void main(String[] args) throws IOException { //1.字节输入流 InputStream in=System.in; //2.字符输入流 InputStreamReader isr=new InputStreamReader(in); //3.将字节输入流转换为缓冲字节输入流 BufferedReader bur=new BufferedReader(isr); //4.字节输出流 PrintStream out=System.out; //5.字符输出流 OutputStreamWriter osw=new OutputStreamWriter(out); //6.将字节输出流转换为缓冲字节输出流 BufferedWriter bufw=new BufferedWriter(osw); String str=null; while((str=bur.readLine())!=null) { if("esc".equals(str)) break; bufw.write(str); bufw.newLine(); bufw.flush(); } } }
运行结果:
java 之 IO 转换流
最新推荐文章于 2022-09-09 14:53:14 发布