Please suggest a method to get similar behavior in Java when we do freopen ("filename", "r", stdin) OR freopen ("filename", "w", stdout) in C.
Assuming this is a stdin / stdout / stderr redirect, look at System.setIn and friends. They allow you to assign different InputStream and PrintStream to System.in , System.out and System.err .
System.setIn
InputStream
PrintStream
System.in
System.out
System.err
See the web page below. There is a solution to what you want to do.
http://techtipshoge.blogspot.com/2011/01/connect-standard-io-to-files.html
Source: https://habr.com/ru/post/1309185/More articles:Error in IE 7 and 8 - javascriptC ++ - Print objects from a set - c ++Constructors in programming languages ââ- javaSleeping thread until an event is visited in another thread from another class - javaHow to check if the result of select mysql expression has a value or not in php? - phpReusing a Hibernate Session in a Stream - javaRegular expression for date - dateIs there a cross-platform API key / value in C ++ or a library for C ++? - c ++Commission Details Service (REST) ââ- xmlGetting a list of words from Trie - javaAll Articles