title: Passing file path as an argument in Java
body: <p>I have been working with buffering a file on my local drive to parse and obtain certain data. For test purposes I was easily able to do it this way:</p>
  
  <pre><code>public static void main(String[] args) {
  
      fileReader fr = new fileReader();
      getList lists = new getList();
  
  
      File CP_file = new File("C:/Users/XYZ/workspace/Customer_Product_info.txt");
      int count = fr.fileSizeInLines(CP_file);
      System.out.println("Total number of lines in the file are: "+count);
  
      List&lt;String&gt; lines = fr.strReader(CP_file);
  
      ....
  
  }
  
  }
  </code></pre>
  
  <p>fileReader.java file has the following function:</p>
  
  <pre><code>public List&lt;String&gt; strReader (File in)
  {
      List&lt;String&gt; totLines = new ArrayList&lt;String&gt;();
  
      try
      {
          BufferedReader br = new BufferedReader(new FileReader(in));
          String line;
          while ((line = br.readLine()) != null)
          {
              totLines.add(line);
          }
          br.close();
      }
      catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
      //String result = null;
  
      return totLines;
  }
  </code></pre>
  
  <p>Now I want the file path to be passed as a Command line Argument instead. I tried a few things but I am kind of new to this and wasnt able to make it work. Can someone please help and explain what all changes I need to make in order to incorporate that change in my code.</p>