title: How do you read and process a line that can have multiple objects on one line JAVA
body: <p>I want to read a CSV file for a number of elements that can either be metal or non-metal and each line in the CSV file can have multiple elements. If it has multiple elements, all rows of the file will have that amount of elements. A valid line will look like:</p>
  
  <pre><code>&lt;symbol,name,atomNum,mass,other/&gt;&lt;symbol,name,atomNum,mass,other/&gt;
  </code></pre>
  
  <p>where other is a character if its a nonmetal and double if its a metal. This is what I have done so far and am not sure how to read in multiple element objects on the line</p>
  
  <pre><code>public static void readValues(String fileName)
  {
      if (!constructed)
      {
          FileInputStream fileStrm = null;
          InputStreamReader rdr;
          BufferedReader bufRdr;
          String line;
          int lineNum;
          try
          {
              fileStrm = new FileInputStream(fileName);
              rdr = new InputStreamReader(fileStrm);
              bufRdr = new BufferedReader(rdr);
              lineNum = 0;
              line = bufRdr.readLine();
              while(line != null)
              {
                  lineNum++;
                  elements[lineNum - 1] = processElements(line);
                  line = bufRdr.readLine();
                  System.out.println(elements);
              }
              fileStrm.close();
          }
          catch(IOException e)
          {
              if(fileStrm != null)
              {
                  try
                  {
                      fileStrm.close();
                      constructed = true;
                  }
                  catch (IOException ex2)
                  {
                  }
              }
              System.out.print("error in file processing: " + e.getMessage());
          }
      }
  }
  
  private static Element processElements(String line)
  {
      char chr;
      Element element;
      String[] lineArray = line.split(",");
      if(lineArray[4] == chr)
      {
          element = new NonMetal();
          elements.setState(lineArray[4]);
      }
      else
      {
          element = new Metal();
          element.setConduct(Double.parseDouble(lineArray[4]));
      }
      element.setSymbol(lineArray[0]);
      element.setName(lineArray[1]);
      element.setAtomNum(Integer.parseInt(lineArray[2]));
      element.setMass(Double.parseDouble(lineArray[3]));
      return elements;
  }
  </code></pre>
  
  <p>I have a super element class and two subclasses, metal and nonmetal, each containing the standard methods for a class</p>