title: Write a program Find that searches all files specified on the command line and prints out all lines containing a specified word
body: <p>Write a program Find that searches all files specified on the command line and prints out all lines containing a specified word. For example, if you call</p>
  
  <p><code>java Find ring report.txt addres.txt Homework.java</code></p>
  
  <p>then the program might print</p>
  
  <pre class="lang-none prettyprint-override"><code>report.txt: has broken up an international ring of DVD bootleggers that
  address.txt: Kris Kringle, North Pole
  address.txt: Homer Simpson, Springfiled
  Homework.java: String filename
  </code></pre>
  
  <hr>
  
  <p>First of all, I could not figure out how to store all the strings that are given in the commandline. Furthermore, my code only prints the part of the line <em>after</em> the found word (so for inst6ance it only prints out: of DVD bootleggers for the first file. How could I solve these issue? Could anyone please help me?</p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;
  
  
  public class P6 {
  
      /**
       * @param args
       * @throws FileNotFoundException 
       */
      public static void main(String[] args) throws FileNotFoundException {
          // TODO Auto-generated method stub
  
  
          for (int i = 0; i&lt;args.length; i++)
          {
              String arg = args[i];
          }
  
          String input = "ring";
  
          File one = new File("report.txt");
          Scanner in = new Scanner(one);
          while (in.hasNext())
          {
              String een = in.next();
  
              if(een.matches(input))
              {
                  System.out.println(in.nextLine());
              }
          }
  
      }
  
  }
  </code></pre>