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 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;

                 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;
                        }

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

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

                        System.out.println("**got "+quantity+" and "+chem);
                    }
                    else
                        allReactants = true;

                } while (!allReactants);

                // mow what do these reactants give us?
            }
        }
        catch (Throwable ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            try
            {
                reader.close();
            }
            catch (Throwable ex)
            {
            }
        }
    }

    private boolean _debug;
}
@@ -237,16 +237,62 @@
 = %22ORE%22;
+%0A    public static final String FUEL = %22FUEL%22;
 %0A%0A    pu
@@ -1351,16 +1351,57 @@
 ptr = 0;
+%0A                 int createsPointer = 0;
 %0A%0A      
@@ -2006,16 +2006,72 @@
 = true;%0A
+                            createsPointer = chemDelim;%0A
         
@@ -2368,16 +2368,109 @@
    else%0A
+                    %7B%0A                        System.out.println(%22Error in parsing line!%22);%0A%0A
         
@@ -2505,16 +2505,38 @@
  = true;
+%0A                    %7D
 %0A%0A      
@@ -2567,24 +2567,24 @@
 eactants);%0A%0A
-
             
@@ -2626,16 +2626,474 @@
 give us?
+%0A%0A                createsPointer += PRODUCES.length() +1;%0A%0A                System.out.println(%22**createsPointer %22+createsPointer);%0A%0A                int createsSpace = line.indexOf(SPACE, createsPointer);%0A                int createsQuantity = Integer.parseInt(line.substring(createsPointer, createsSpace));%0A                String chemCreated = line.substring(createsSpace +1);%0A%0A                System.out.println(%22**creates %22+createsQuantity+%22 %22+chemCreated);
 %0A       

Update Parser.java