Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
183 views
in Technique[技术] by (71.8m points)

java - I/O redirection in Eclipse?

Is it possible to use I/O redirection in Eclipse?

I want to redirect standard input/output on the command line like java MyProgram <input.txt >output.txt, but I can't seem to get it to work in Eclipse. I tried including the <'s as part of the program arguments, which was ignored, and also in the VM arguments, which just threw up a class not found error. How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...