读取键盘输入的字母,并转换成大写输出在控制台上


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


public class SystemInput
{
//读取键盘录入的字母,并将所有字母转换成大写字母输出在控制台上
public static void main(String[] args)
{
//
SystemInDemo1();

}

private static void SystemInDemo1() {
// 读取一个键盘录入的数据并打印在控制台上
BufferedReader bis = null;
BufferedWriter bos = null;

bis = new BufferedReader(new InputStreamReader(System.in));

bos = new BufferedWriter(new OutputStreamWriter(System.out));

String len = null;
try {
while((len=bis.readLine())!=null)
{
String s = len.toUpperCase();
bos.write(s);
bos.newLine();
bos.flush();

}
} catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
bis.close();
} catch (IOException e)
{
e.printStackTrace();
}
try
{
bos.close();
} catch (IOException e)
{
e.printStackTrace();
}
}

}

}



运行程序


java—IO流——读取键盘输入的字母并转换成大写字母输出在控制台上_数据