标签:style blog http io ar os sp java 数据
原文地址:http://blog.csdn.net/qingdujun/article/details/41175021
实现从键盘输入一行数据,并输出在屏幕上面。
package io.dol.sn; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; //实现键盘录入,每次读入一行 public class ReadLineDemo { public static void main(String[] args) throws IOException { //——键盘录入的最常见写法: //1、read()是字节流InputStream的方法; //2、readLine()是字符流缓冲区BufferedReader的方法; //System.in为中的in为标准输入流对象,为InputStream类型; //3、将字节流转化为字符流,InputStreamReader; //4、将字符流转换为字节流,OutputStreamReader; //为了提高效率,对字符流进行缓冲技术操作BufferedReader; BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in)); //——屏幕输出最常见写法: BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(System.out)); String line = null; while ((line=bufr.readLine())!=null) { if ("over".equals(line)) break; bufw.write(line.toUpperCase()); bufw.newLine(); bufw.flush(); } bufr.close(); bufw.close(); } }原文地址:http://blog.csdn.net/qingdujun/article/details/41175021
标签:style blog http io ar os sp java 数据
原文地址:http://blog.csdn.net/qingdujun/article/details/41175021