IO流将字符串变为大写输出

//public class SystemIn {
//    public static void main (String[] args) throws Exception{
//        InputStreamReader isr=new InputStreamReader(System.in);//System.in是一个InputStream 外面套一层转换流(包装流)
//        BufferedReader br=new BufferedReader(isr);//在这里再套一层缓冲流(包装流)
//        while(true){
//            System.out.println("请输入字符串:");
//            String data=br.readLine();
//            if("exit".equalsIgnoreCase(data)||"e".equalsIgnoreCase(data)){
//                System.out.println("程序结束!");
//                break;
//            }
//            String upperCase=data.toUpperCase();
//            System.out.println(upperCase);
//        }
//    }
//}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 相当于将标准的输入流与与缓冲流联系了起来!!
 */
public class SystemIn{
    public static void main(String[] args) throws IOException {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br= new BufferedReader(isr);
        while(true){
            System.out.println("请输入字符串:");
            String str = br.readLine();//将从键盘输入的数据输入到了这个缓冲区中(应该就是一部分内存)
            if("exit".equalsIgnoreCase(str)){
                System.out.println("程序结束!");
                break;
            }
            String toUpperCaseString = str.toUpperCase();
            System.out.println(toUpperCaseString);
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值