0

I'm trying to pass a .txt file as a paramater into my java program.

My program is titled SetTest and the file I'm trying to read is Ted.txt. From a Windows 7 command prompt I create a temp folder and compile my program there creating SetTest.class. Also in that folder is Ted.txt. From that temp directory I then issue the command:

java SetTest < Ted.txt

Everything works as expected. The program reads in the file and outputs what I'm looking for. All good.

My question is how do I duplicate this using Eclipse? I believe my text file is in the proper location, listed under JRE System Library as seen in the Package Explorer. I've been trying the following from Eclipse: Run -> Run Configurations... Then in the (x)= Arguments section, in the Program arguments field I enter Ted.txt then click on Run. Unfortunately nothing seems to happen. No error message, but I don't see the console output I'm looking for either.

Dan Schwartz
  • 1
  • 1
  • 2

1 Answers1

0

To rephrase your question - you want to send a file to your application's standard input, while it is running in Eclipse.

You can write (copy & paste) data into console (that's where the standard input is taken from). However I am not aware of any possibility how you can redirect file contents directly to the standard input.


UPDATE with correct keywords you might be able to find more resources:

Community
  • 1
  • 1
Pavel Horal
  • 17,782
  • 3
  • 65
  • 89