import java . io .* ;public class StandardIO{ public static void main (String [ ] args) throws IOException { PrintStream console = System . out ; // InputStream stdin = System .in ; // 為什么不需要恢復(fù)該對(duì)象 BufferedInputStream in = new BufferedInputStream ( new FileInputStream ("StandardIO.java")) ; PrintStream out = new PrintStream ( new BufferedOutputStream ( new FileOutputStream ("test.out"))) ; System . setIn (in) ; System . setOut (out) ; System . setErr (out) ; BufferedReader br = new BufferedReader ( new InputStreamReader (System . in )) ; String s ; while ( ( s = br . readLine ( ) ) != null ) { System . out . println ( s ) ; } out . close ( ) ; System . setOut (console) ; } }
1 回答

POPMUISE
TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊
你也可以試試不恢復(fù) System.out 看會(huì)咋個(gè)樣。
理論上來說,程序都結(jié)束了,恢復(fù)不恢復(fù)都沒關(guān)系了。
添加回答
舉報(bào)
0/150
提交
取消