I/O redirection in Eclipse?

后端 未结 2 1313
滥情空心
滥情空心 2020-12-07 01:52

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

2条回答
  •  鱼传尺愫
    2020-12-07 02:01

    You can redirect output using the Run dialog, Common tab, "Standard Input and Output" section.

    However, it doesn't look like you can redirect input as far as I can tell (and as far as this Stack Overflow question can tell, too).

    How much control do you have over your application? If you don't mind a bit of a hack, you could have a couple of properties or command line arguments to determine the appropriate files, and use System.setOut and System.setIn accordingly. It is a bit of a hack though...

提交回复
热议问题