Java Text Files
<p>Im lost at what im doing with text file java, any assistance or help would be helpful.</p>

<p>"Create a class Inventory. This class should implement (at least) the method below: a. The static method main, which receives an array of strings. The array should have two elements: the path where the files are located (at index 0), and the name of the files to process (at index 1). For example, if the name was “foodLion” then the program should use “foodLion.cmd” (from which it will read commands) and “foodLion.pro” (from which it will read/write products). To create a File object for these files, make sure to use the path provided in index 0. To that end, the name of your files will be: path + FILE_SEPARATOR + name FILE_SEPARATOR is obtained by calling System.getProperty( "file.separator" ) – which returns either a slash if executed in a UNIX-based OS (like Macs) or a backslash in Windows. If main receives an array with a length different than 2 elements then your program should print the following message to the screen and terminate normally: Usage: java Inventory Incorrect number of parameters. DEL,9 If main receives a file name (e.g., “harrisTeeter”) but there were no commands file with that name (e.g., “harrisTeeter.cmd”) in the path then your program should print the following message (where name is the provided file name) before terminating: Usage: java Inventory The commands file "name.cmd" does not exist. If main received a name (e.g., “tradersJoe”) but the products file (e.g., “tradersJoe.pro”) is not found, your program should print the following message before terminating: Usage: java Inventory The products file "name.pro" does not exist. If main received a name, and the products and commands files exist, then your program should read these files and process the commands using the list of products (as indicated earlier). (Hint: for Scanner to read CVS text files, set its delimiter to “\r\n|\n|,”, which allows it to skip commas and EOL characters (under Windows and else) and read the next element right away). Once all commands have been processed, your program should overwrite the products file with all current products. All products in this file must be sorted by ID (from lower to higher). (Hint: use Comparable to enable sorting.) Also remember to close all open files before ending your program."</p>

<p>My program:</p>

<pre><code>                  import java.io.File;
                  import java.io.FileNotFoundException;
                  import java.io.PrintWriter;
                  import java.util.ArrayList;
                  import java.util.Scanner;
                  import java.util.jar.Attributes.Name;







    public class Inventory {

public static &lt;Path&gt; void main(String args[]) {

    ArrayList&lt;Path&gt; path = new ArrayList&lt;Path&gt;();
     ArrayList&lt;Name&gt; list = new ArrayList&lt;Name&gt;();
        try{
            File    file  = new File   ( "input.txt" );
            Scanner scan  = new Scanner( file );
            scan.useDelimiter("\r\n|\n|,");
            while (scan.hasNext()){
                String path1 = scan.next();
                String name = scan.next();

                list.add(name + "," + path1 + ",");
            }
            scan.close();
        }
    catch (FileNotFoundException e) {

        e.printStackTrace();
    }


    try {
        File file          = new File("output.txt");
        PrintWriter writer = new PrintWriter( file );
        for(Name s : list){
            writer.println(s);
        }
        writer.close();
    }
    catch (FileNotFoundException e) {
    }
}
</code></pre>

<p>}</p>
