- package com.itheima.day19;
- import java.io.*;
- public class InputStramInDemo {
- /**
- * InputStream键盘输入
- * @throws IOException
- */
- public static void main(String[] args) throws IOException {
- //键盘的最常见写法。
- BufferedReader bufr =
- new BufferedReader(new InputStreamReader(System.in));
- BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(System.out));
- String line = null;
- while((line=bufr.readLine())!=null)
- {
- if("over".equals(line))
- break;
- bufw.write(line.toUpperCase());
- bufw.newLine();
- bufw.flush();
- }
- bufr.close();
- }
- }
复制代码- package com.itheima.day19;
- import java.util.*;
- public class scannerDemo {
- /**
- * @param args
- */
- public static void main(String[] args) {
- Scanner sn=new Scanner(System.in);
- String in=null;
- while(!("over").equals(in)){
- in=sn.next();
-
- System.out.println(in);
-
- }
- System.out.println("已经退出");
- sn.close();
- }
- }
复制代码 |