You can use OS redirection operators
java Test < inputFile > outputFile
then this
public class Test {
public static void main(String[] args) throws IOException {
for(int i; (i = System.in.read()) != -1;) {
System.out.write((byte)i);
}
}
}
will copy from inputFile to outputFile
7
solved Give standard input to program through files and take standard output to a file [closed]