package test; import java.io.*; import java.util.*; import privateclass.MyBufferedReader; public class Main { private static final String space_operator = " "; private static final double pi = Math.PI; private static final String LINE_SEPARATOR = System.getProperty("line.separator"); public static void main(String[] args) throws Exception { //我们用buffered的时候操作流,只要是流就可以操作 //读文件等等 //BufferedReader bfr = new BufferedReader(new InputStreamReader(new FileInputStream("demo.txt"))); //BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("kuku.txt"))); /** * BuferedReader 缓冲区 *我们将字节流转换成为字符流 *System.in是字节流 == IntputStream *然后我们用到工具InputStreamReader转换成为字符流 *放到缓冲区里面这样速度更加的快 */ BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bfw = new BufferedWriter(new OutputStreamWriter(System.out)); String line = null; while((line = bfr.readLine()) != null) { if(line.equals("over"))break; bfw.write(line.toUpperCase()); bfw.newLine(); bfw.flush(); } } }
原文:https://www.cnblogs.com/WINDZLY/p/11788809.html