BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
是怎样简化而来的????
public static void getBufferedStream()throws IOException
{
//获取键盘录入对象
InputStream in = System.in;
//将字节流对象转化成字符流对象,使用转换流InputStreamReader
InputStreamReader isr = new InputStreamReader(in);// 读取转换流
//为了提高效率,将字符串进行缓冲区技术高效操作,使用BufferedReader
BufferedReader bufr = new BufferedReader(isr);
String line = null;
while((line = bufr.readLine()) != null)
{
if("over".equals(line))
break;
System.out.println(line.toUpperCase());
}
bufr.close();
}
通过该程序可将键盘输入数据在控制台中读取到。 |
|