import java.io.*;
public class TestTransformReader {
public static void main(String[] args) {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);//这里再套用缓冲流是因为要用到readLine()方法
String str = null;
try{
str = br.readLine();
while(str != null){
if(str.equalsIgnoreCase("exit")){
break;
}
System.out.println(str.toUpperCase());
str = br.readLine();
}
br.close();
}catch(IOException ioe){
ioe.printStackTrace();
}
}
}
IOException涵盖了大部分io报错,比如
FileNotFoundException。