Eclipse reading stdin (System.in) from a file

Kevin picture Kevin · Oct 9, 2008 · Viewed 74.2k times · Source

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

Answer

Michael Myers picture Michael Myers · Oct 9, 2008

Pure Java

You can redirect System.in with a single line of code:

System.setIn(new FileInputStream(filename));

See System.setIn().

Eclipse config

In Eclipse 4.5 or later, the launch configuration dialog can set System.in to read from a file. See the announcement here.

Common tab of Launch Configuration dialog