//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);
}
}
}
IO流将字符串变为大写输出
最新推荐文章于 2021-07-08 10:24:12 发布