import java.util.*;
import java.io.*;

public class Parser
{
    public static final String DELIMITER = ",";
    public static final String PRODUCES = "=>";
    public static final String SPACE = " ";
    public static final String ORE = "ORE";
    public static final String FUEL = "FUEL";

    public Parser (boolean debug)
    {
        _debug = debug;
    }

    public void loadData (String fileName)
    {
        /*
         * Open the data file and read it in.
         */

        BufferedReader reader = null;
        String[] values = null;

        try
        {
            reader = new BufferedReader(new FileReader(fileName));
            String line = null;

            while ((line = reader.readLine()) != null)
            {
                System.out.println("**read "+line);

                /*
                 * Line format:
                 * 
                 * - ALWAYS start with a number
                 * - ALWAYS follow with a String
                 * - Then EITHER a comma if more than one chemical OR => to denote end of reactants
                 * - ALWAYS end in a number and a String
                 */

                 Vector<Integer> quantities = new Vector<Integer>();
                 Vector<Chemical> chemicals = new Vector<Chemical>();
                 boolean allReactants = false;
                 int ptr = 0;
                 int createsPointer = 0;

                 do
                 {
                    int quantitySpace = line.indexOf(SPACE, ptr);

                    if (quantitySpace != -1)
                    {
                        int quantity = Integer.parseInt(line.substring(ptr, quantitySpace));
                        int chemDelim = line.indexOf(DELIMITER, quantitySpace);
                        String chem = null;

                        if (chemDelim == -1)  // no more chemicals
                        {
                            chemDelim = line.indexOf(PRODUCES, quantitySpace);
                            allReactants = true;
                            createsPointer = chemDelim;
                        }

                        chem = line.substring(quantitySpace+1, chemDelim);

                        ptr += chemDelim +2;  // move on past comma and space!

                        System.out.println("**got "+quantity+" and "+chem);
                    }
                    else
                    {
                        System.out.println("Error in parsing line!");

                        allReactants = true;
                    }

                } while (!allReactants);

                // mow what do these reactants give us?

                createsPointer += PRODUCES.length() +1;

                System.out.println("**createsPointer "+createsPointer);

                int createsSpace = line.indexOf(SPACE, createsPointer);
                int createsQuantity = Integer.parseInt(line.substring(createsPointer, createsSpace));
                String chemCreated = line.substring(createsSpace +1);

                System.out.println("**creates "+createsQuantity+" "+chemCreated);
            }
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }
    }

    private boolean _debug;
}
@@ -371,12 +371,24 @@
 lic 
-void
+Vector%3CReaction%3E
  loa
@@ -548,32 +548,93 @@
 %5D values = null;
+%0A        Vector%3CReaction%3E reactions = new Vector%3CReaction%3E();
 %0A%0A        try%0A  
@@ -704,24 +704,24 @@
 fileName));%0A
-
             
@@ -731,32 +731,77 @@
 ing line = null;
+%0A            Reaction react = new Reaction();
 %0A%0A            wh
@@ -1258,147 +1258,8 @@
 */%0A%0A
-                 Vector%3CInteger%3E quantities = new Vector%3CInteger%3E();%0A                 Vector%3CChemical%3E chemicals = new Vector%3CChemical%3E();%0A
     
@@ -3339,24 +3339,51 @@
  %7D%0A        %7D
+%0A%0A        return reactions;
 %0A    %7D%0A%0A    

Update Parser.java