Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

core java program needs input  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose you are sending a Java program for a contest. How would you want it to take input from? You are free to implement any way for feeding input to it, what would you choose - console, file or something else?

How is this idea? An input.text file, must be kept at the same location of program, must have data in a particular format - program has its name hard coded and will read it through File IO API.

Any other opinion/suggestions?

Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the input.

If it's something singular and short then a command line argument would be the easiest.

If one questions given depend on the answers already given then I would prompt the user while the program is executing.

If I wanted to be able to pipe the data to the program from the output of another's output then stdin would be best.

If it's multiple lines of text or binary data, then reading it from a file might be the best option.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!