title: How to takes a filename from the command line & outputs that file heap sorted?
body: <p>I'm new to java and would appreciate it if someone could give me some help. Thanks in advance.</p>
  
  <p>I am trying to take a filename from the command line and output that file sorted (from my Heap.java) and print it out one word per line.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>public class HeapSort {
  
  public static void main(String[] args) throws IOException {
    //public static void main(String[] args)  {   
  
  
      // Declare and instantiate a new ArrayList object
         ArrayList&lt;String&gt; data = new ArrayList&lt;String&gt;(); 
  
      //Declare the input file names
        String inFile = "data2415.txt";
  
       Scanner sc = new Scanner(new File(args[0]));
  
        if (0 &lt; args.length){
           String filename = args[0];
            File file = new File(filename);
        }
  
          //h = reader.readLine();
  
        while (sc.hasNext()) data.add(sc.next());
  
        }
  
  
  }
  </code></pre>