title: Java args command line parameter-- trying to pass filename as parameter in args to a method but not working
body: <p>I'm fairly new to Java. Currently trying to have the filename given in args[] passed to this FileReader but when I compile it says it can't find the specified file. If I hardcode the filename it works fine. How's this supposed to work? </p>
  
  <pre><code>public class StringSplit
  {
  
     public void parseCommands
     {
       try
       {
         //not working, why? It works if I do FileReader fr= new FileReader("hi.tpl").
         FileReader fr= new FileReader(args);
  
       }
  
   public static void main (String[] args)// args holds the filename to be given to FileReader
   {
    if (args.length==0)
     {
       System.out.println("Error: Bad command or filename. Syntax: java [filename.tpl]);
       System.exit(0)
     }
     StringSplit ss= new StringSplit();
     ss.parseCommands();
    }
  
  }
  </code></pre>