how to redirect stdin and stdout to a text file in java
java
Solution
You don't have to do that in Java, you can do it from the shell that runs your Java application:
# cat input.txt | java -jar myapp.jar > output.txt
The Java code can then just read from System.in and write to System.out.
Problem
How to redirect stdin and stdout to take data as input from a text file and pass data as output to another textfile. My input and output files look like this. Input File.txt ``` 1 2 3 ``` The output should be the sum of the numbers in the input file. Output File.txt ``` 6 ```