开发者

Equivalent of freopen in Java

开发者 https://www.devze.com 2022-12-29 09:00 出处:网络
Please suggest a method to obtain a simila开发者_运维技巧r behaviour in Java as when we do freopen(\"filename\",\"r\",stdin) OR freopen(\"filename\",\"w\",stdout) in C.Assuming that this is to redirec

Please suggest a method to obtain a simila开发者_运维技巧r behaviour in Java as when we do freopen("filename","r",stdin) OR freopen("filename","w",stdout) in C.


Assuming that this is to redirect stdin/stdout/stderr, have a look at System.setIn and friends. They allow you to assign a different InputStream and PrintStream to System.in, System.out and System.err.


See the webpage below. There's a solution to what you wanna do.

http://techtipshoge.blogspot.com/2011/01/connect-standard-io-to-files.html

0

精彩评论

暂无评论...
验证码 换一张
取 消