views:

2753

answers:

3

Is it possible for Eclipse to read stdin from a file?

+1  A: 

I don't know how you might get Eclipse to do it, but the redirect itself is only one line of code:

System.setIn(new FileInputStream(filename));

See System.setIn().


EDIT: For redirecting in Eclipse's config, this post is the best I can find.

Michael Myers
Thanks but I'm looking for a configuration option external to my software
+2  A: 

I don't see a nice way to do it using the standard Eclipse Run dialog. However, you might be able to do it with an External tool launcher and either use the standard "< infile" syntax or call a .bat/.sh script to do it for you.

It's not automated, which is what I'm guessing you want, but you can copy & paste the contents of your infile to the Eclipse console when you launch your program.

KC Baltz
+1  A: 

On the "common" tab of the run dialog, under "Standard Input and Output" there's a checkbox for "file". but it appears to be only for output...

I'd expect to see 2 file fields there, one for standard in, one for standard out with the append options.

John Gardner