标准输入输出流
/**
* @description StandardIO
* @author 小邱
* @version 0.0.1
* @since 2021/9/9 13:54
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class StandardIOTest {
/*
InputStream System.in:系统标准的输入设备(默认键盘)
PrintStream System.out:系统标准的输出设备(默认显示器)
System方法对默认设备进行改变:
System.setIn(InputStream in)
System.setOut(PrintStream out)
*/
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 = null;
data = br.readLine();
if ("e".equalsIgnoreCase(data) || "exit".equalsIgnoreCase(data)) {
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();
}
}
}
}