package cn.io; import java.io.*; //键盘输入,控制台输出,在遇到over时候结束 public class Test8 { public static void main(String[] args) { InputStream is = null; InputStreamReader isr = null; BufferedReader br = null; OutputStream os = null; OutputStreamWriter osw = null; BufferedWriter bw = null; is = System.in; isr = new InputStreamReader(is); br = new BufferedReader(isr); //BufferedReader br=new BufferedReader(new InputStreamReader(System.in));三句合写 os = System.out; osw = new OutputStreamWriter(os); bw = new BufferedWriter(osw); //BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));三句合写 String line = null; try { while ((line = br.readLine()) != null) {// 读到键盘输入的一行 if (!("over".equals(line))) {//不要写s.equals("over");要防止s为空的情况报错 bw.write(line.toUpperCase()); bw.newLine(); bw.flush(); } else { break; } } } catch (IOException e) { e.toString(); } finally{ if(bw!=null){ try { bw.close(); } catch (IOException e) { e.toString(); } } if(br!=null){ try { br.close(); } catch (IOException e) { e.toString(); } } } } }