title: How to read int,text and double from a file and store it into an arraylist?
body: <p>What I am trying to do is read a text file which has this lines</p>
  
  <p>232131231, random name, 23.3232</p>
  
  <p>I only know how to read it as a String of the whole line. I don't know how to read them individually. This is my test codes.</p>
  
  <p>main</p>
  
  <pre><code>   public class JavaApplication9 
  {
      int value1;
      String value2;
      double value3;
      ArrayList&lt;String&gt; toBeSplit = new ArrayList(); 
      String[] split;
      ArrayList &lt;Inventory&gt; productList = new ArrayList&lt;&gt; ();
  
      public long ReadFile(String sfile) throws IOException 
              {       
                  int x = 0;
                  File inFile = new File(sfile);
                  BufferedReader reader = new BufferedReader(new FileReader(inFile));
                  String sline = null;
                  while ((sline=reader.readLine()) != null) 
                      {
                          toBeSplit.add(x,sline);
                          x++;
                      }
                  reader.close();  
                  return inFile.length();
              }
  
      public void splitString ()
      {   
          int a = 0;
          while (a&lt;toBeSplit.size())
          {
              split = toBeSplit.get(a).split(",");            
              value1 = Integer.parseInt(split[0]);
              value2 = split[1];
              value3 = Double.parseDouble(split[2]);
              productList.add(new Inventory (value1,value2,value3));
              a++;
          }
      }
  
      public void OutputLines ()
      {
           for (Inventory e : productList)
          {
              System.out.println (e.getBarcode() +"\t"+ e.getName()+"\t"+ e.getPrice());
          }
      }
  
      public static void main(String[] args)  
      {
          try
          {
              JavaApplication9 instance = new JavaApplication9 ();
              instance.ReadFile("Products (1).csv");
              instance.splitString();
              instance.OutputLines();
          }
          catch (IOException e)
          {
              System.out.print ("Error");
          }
      } 
  }
  </code></pre>
  
  <p>and my Inventory class</p>
  
  <pre><code>    public class Inventory
  {
      int barcode;
      String name;
      double price;
  
     public Inventory (int bars,String pname,double prices)
      {
          barcode = bars;
          name = pname;
          price = prices;
      }
  
      public int getBarcode ()
      {
          return barcode;
      }
  
      public String getName ()
      {
          return name;
      }
  
      public double getPrice ()
      {
          return price;
      }
  
  }
  </code></pre>