I know when using C++ you can do the following to read in a list of commands from a text file, run them against the program, and output the results to a text file:
ExampleProg < test.txt > results.txt
Can anyone tell me how to get the same result, but using a Java program. I do most programming in an IDE, so I'm not all that great with knowing what commands need to be done at the command line.
if you have JAR build you can use
java -jar your_file test.txt >> output.txt
or if you have compiled class files
java classfile.class test.txt >> output.txt
Java also uses main() function, there your arguments can be parsed.
Last edited by postmortem; September 30th, 2009 at 11:33 PM.
If you use the -jar option make sure you don't forget the .jar extension (printStatement.jar in this case). Also use redirection for the input file (<Input.txt) unless you read the file name from the arguments list and open the file yourself. With redirection you just use System.in.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.