- import java.io.*;
- class Test121 {
- public static void main(String[] args) {
- BufferedReader bfr = null;
- try {
- while (true) {
- bfr = new BufferedReader(new InputStreamReader(System.in)); //此处输入不应改为System.io
- String strLine = bfr.readLine();
- if (strLine != null) {
- System.out.println("hi:" + strLine);
- } else {
- return;
- }
- }
- }
- catch (IOException e) {
- System.out.println(e.toString());
- }
- finally {
- try {
- bfr.close();
- } catch (IOException e) {
- System.out.println("关闭异常");
- }
- }
- }
- }
复制代码 |