1 /*
2
3 通过键盘录入一行数据并打印其大写.
4
5 */
6 import java.io.*;
7
8 class TransStreamDemo
9 {
10 public static void main(String[] args) throws IOException
11 {
12 //获取键盘录入对象。
13 //InputStream in = System.in;
14
15 //将字节流对象转成字符流对象,使用转换流。InputStreamReader
16 //InputStreamReader isr = new InputStreamReader(in);
17
18 //为了提高效率,将字符串进行缓冲区技术高效操作。
19
20 //BufferedReader bufr = new BufferedReader(isr);
21
22
23 //键盘的最常见写法。
24 BufferedReader bufr =
25 new BufferedReader(
26 new InputStreamReader(System.in));
27
28
29
30
31
32
33 // OutputStream out = System.out;
34 // OutputStreamWriter osw = new OutputStreamWriter(out);
35 // BufferedWriter bufw = new BufferedWriter(osw);
36 BufferedWriter bufw =
37 new BufferedWriter(
38 new OutputStreamWriter(System.out));
39
40
41
42
43 String line = null;
44
45 while((line=bufr.readLine())!=null)
46 {
47 if("over".equals(line))
48 break;
49 bufw.write(line.toUpperCase());
50 bufw.newLine();
51 bufw.flush();
52 }
53
54 bufr.close();
55
56 }
57 }