
/*
1.标准的输入输出流<br /> 1.1<br /> System.in:标准的输入流,默认从键盘输入<br /> System.out:标准的输出流,默认从控制台输出<br /> 1.2<br /> System类的setIn(InputStream is) / setOut(PrintStream ps)方式重新指定输入和输出的流<br /> 1.3练习:<br /> 从键盘输入字符串,要求将读取到的整行字符串转成大写输出。然后继续进行输入操作,<br /> 直至当输入“e”或者“exit”时,退出程序。<br /> 方法一;使用Scanner实现,调用next()返回一个字符串<br /> 方法二:使用System.in实现。System.in ---> 转换流 --->BufferedReader的readLine()
package com.atguigu.java2;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;/*** 1.标准的输入输出流*** @author Dxkstart* @create 2021-05-31 10:25*/public class OtherSystemTest {/*1.标准的输入输出流1.1System.in:标准的输入流,默认从键盘输入System.out:标准的输出流,默认从控制台输出1.2System类的setIn(InputStream is) / setOut(PrintStream ps)方式重新指定输入和输出的流1.3练习:从键盘输入字符串,要求将读取到的整行字符串转成大写输出。然后继续进行输入操作,直至当输入“e”或者“exit”时,退出程序。方法一;使用Scanner实现,调用next()返回一个字符串方法二:使用System.in实现。System.in ---> 转换流 --->BufferedReader的readLine()*/public static void main(String[] args) {BufferedReader br = null;try {InputStreamReader isr = new InputStreamReader(System.in);br = new BufferedReader(isr);while(true){System.out.println("请输入字符串:");String data = br.readLine();if(data.equalsIgnoreCase("e") || data.equalsIgnoreCase("exit")){System.out.println("程序结束");break;}String uppercase = data.toUpperCase();System.out.println(uppercase);}} catch (IOException e) {e.printStackTrace();} finally {try {if(br != null) {br.close();}} catch (IOException e) {e.printStackTrace();}}}}
