Äquivalent freopen in Java
Frage
vorschlagen Bitte geben Sie eine Methode ein ähnliches Verhalten in Java zu erhalten, wie wenn wir das tun freopen ( "Dateiname", "r", stdin) OR freopen ( "Dateiname", "w", stdout) in C.
Lösung
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
.
Andere Tipps
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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow