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。接受屏幕输入转换为大写 via InputStreamReader & System.in
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.