import java.io.*;
public class TransStreamDemo2 {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
//获取键盘录入对象
InputStream in = System.in;
//将字节流对象转成字符流对象,使用转换流。InputStreamReader
InputStreamReader isr = new InputStreamReader(in);
//为了提高效率,将字符串进行缓冲区技术高效操作,使用BufferedReader
BufferedReader bufr = new BufferedReader(isr);
//BufferedReader bufr = new BufferedReader(new FileInputStream("CopyPic.java"));
OutputStream out = System.out;
OutputStreamWriter osw = new OutputStreamWriter(out);
//OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("e:\\out.txt"));
BufferedWriter bufw = new BufferedWriter(osw);
String line = null;
while((line=bufr.readLine())!=null){
if("over".equalsIgnoreCase(line)){
break;
}
bufw.write(line.toUpperCase());
bufw.newLine();
bufw.flush();
}
bufr.close();
}
}
//读取流、写入流代码三句简化成一句
//读取流:(读取)键盘录入--键盘的简单写法
//BufferedReader bufr = new BufferedReader(new InputStreamReader(System.in));
//写入流:
//BufferedReader bufr = new BufferedReader(new OutputStreamReader(System.out));
|
|