JAVA#标准输入输出——大小写转换练习'札记

public class TestotherStream {
    public static void main(String[] args) {
        BufferedReader br=null;
        try{
        InputStream is=System.in;
        InputStreamReader isr=new InputStreamReader(is);
         br=new BufferedReader(isr);
        System.out.println("请输入字符串:");
        String str;
        while(true) {
            str=br.readLine();
            if (str.equalsIgnoreCase("e") || str.equalsIgnoreCase("exit")) {
                break;
            }
            String str1 = str.toUpperCase();
            System.out.println(str1);
        }
        }catch(IOException e){
            e.printStackTrace();
        }finally {
            try {
                if(br!=null){
                    br.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
请输入字符串:
dsfsf
DSFSF
exit

猜你喜欢

转载自blog.csdn.net/Iverson941112/article/details/85084760
今日推荐