Java – Eclipse reading stdin ( from a file

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

Best Answer

Pure Java

You can redirect 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 to read from a file. See the announcement here.

Common tab of Launch Configuration dialog