本帖最后由 悟佛修道 于 2013-6-4 23:06 编辑
- class TransStreamDemo2
- {
- public static void main(String[] args) throws IOException
- {
- System.setIn(new FileInputStream("PersonDemo.java"));
- System.setOut(new PrintStream("zzz.txt")); 当这行写出来后 下面的system.out还会不会执行???如果不会执行相当于就废了?
- //键盘的最常见写法。
- 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();
- }
- }
复制代码 System.setOut(new PrintStream("zzz.txt"));
BufferedWriter bufw = new BufferedWriter(new OutputStreamWriter(System.out));
这两句有联系没啊?是不是其中只能存在一句?
|