Saturday, April 30, 2011

Changing System.in in eclipse to read from a file

This seems like kind of a silly question but is there a way to change the standard in in eclipse. If I was doing this from the windows console it would look like "java myprogram < stdin.txt"

From stackoverflow
  • The way you do this in VS is to set the command line arguments when debugging to "< stdin.txt". Maybe the same will work in Eclipse? I'd check but I don't have it on this machine.

  • Here is a (fairly ugly) solution, as pointed out in this comment

  • I am using Eclipse 3.4 and I see a place to enter a file for stdin/stdout on the Common tab of a Java Application Run configuration. I am not exactly sure if it will work for stdin, but it is worth a try.

0 comments:

Post a Comment