Is it possible to use I/O redirection in Eclipse?
I want to redirect standard input/output on the command line like java MyProgram output.txt, but I can't seem to get it to work in Eclipse. I tried including the
解决方案
To truly redirect both, the simplest way is still to define your program as an external script
"java %1 %2 %3 %4 < %5 > %6"
(adapt the number of parameters to your particular program)
In the Run menu, click 'External Tools.../Open External Tools Dialog" and define an external launch configuration in which you will specify both the arguments and the input and output file.
It is not an ideal solution though, as you cannot debug directly your code (with a "debug" launcher configuration).
Instead you have to remote debug it (add '-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000' in your generic Java launcher script)
Once you have launched your external tool, launch a remote debug session through the "debug launcher 'Remote Java Application'" section: