title: How to input a text file into a java program via terminal (like how it's done in C++)?
body: <p>If i do </p>
  
  <blockquote>
    <p><code>$ java ProgramName string1 string2 string3</code></p>
  </blockquote>
  
  <p>from the linux terminal, ProgramName gets string1 string2 string3 via <code>main(String arg[])</code> using <code>arg[i]</code>, and all is well.</p>
  
  <p>Here's what I want to do:
  Instead of typing <code>string1 string2 string3</code> at the terminal, i want to type</p>
  
  <blockquote>
    <p><code>$ java ProgramName &lt; input.txt</code></p>
  </blockquote>
  
  <p>where "input.txt" contains string1, string2, and string3</p>
  
  <p>Edit:
  "input.txt" has one word on a separate line with an 'enter' at the end of the line</p>
  
  <pre><code>string1
  
  string2
  
  stringn
  </code></pre>
  
  <p>This can be done it C++ ; can it be done similarly in Java?</p>