字符流与字节流转换输出
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); // BufferedWriter buw=new BufferedWriter(new OutputStreamWriter(System.out));;//打印到控制台 BufferedWriter buw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("D:\\demo.txt")));//输出到文件 String line=null; while((line=buf.readLine())!=null) { if(line.equals("over")) { break; } buw.write(line.toUpperCase()); buw.newLine(); buw.flush(); }