title: How to put tokens read from a csv file into an array of objects
body: <p>I am writing a program that reads from a csv file and puts the values into an array of objects. So I set up an object class that has 5 attributes . What I can't seem to get is how to put the tokenized variables into my array of objects. I did a system.out.printf that uses the getters from my object class to print out the object instances in each index but I get a null pointer. So my guess is that the tokens aren't being stored in my array of objects so how can this be done? This is what I have so far.</p>
  
  <p>EDIT: This is one of the lines on my CSV file 
  12345,Left-Handed Bacon Stretcher,125.95,PGH,2</p>
  
  <p>EDIT: This is the stacktrace error Im getting for those asking
      java.lang.NumberFormatException: For input string: " 5"
      at java.lang.NumberFormatException.forInputString(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at Prog6.main(Prog6.java:97)</p>
  
  <pre><code>Part[] part = new Part[20];
  
  String partNumber;
  String description;
  double price = 0.0;
  String warehouseID;
  int quantity = 0;
  
  try
  {
  inFile = new Scanner( new File( "parts.txt" ) );
  }
  catch( FileNotFoundException e )
  {
  System.out.println( "Error: File parts.txt not found" );
  }
  
  // read file
  try
  {
  
  while ( inFile.hasNext() )
  {
  String record = inFile.nextLine();
  String[] tokens = record.split(",[ ]*");
  
  partNumber = tokens[0];
  description =  tokens[1] ;
  price = Double.parseDouble( tokens[2] );
  warehouseID =  tokens[3] ;
  quantity = Integer.parseInt( tokens[4] );
  
  part[num] = new Part( partNumber, description, price, warehouseID, quantity );
  num++;
  
  }
  }
  catch( Exception e )
  {
  System.out.println( "File error " + e.getMessage() );
  }
  
  // close file
  inFile.close();
  </code></pre>