View Single Post
  #4 (permalink)  
Old 03-13-2008, 04:42 PM
markyoung1984 markyoung1984 is offline
Member
 
Join Date: Mar 2008
Posts: 3
markyoung1984 is on a distinguished road
Need to add elements
Thanks for your replies, that works fine. My program now compiles but I have an issue when adding things to the list (siteList). My program basically reads in a line from a file and then splits it into tokens and stores these in an array temporarily. The values in this array (lineContents) are then written to an object constructor of type site. However, when doing this using the code below, I get a Null Pointer Exception. Let me know your thoughts.

Code:
List siteList; while ((line = in.readLine()) != null){ //whilst there are lines in the file StringTokenizer st = new StringTokenizer(line, ","); while (st.hasMoreTokens()) { lineContents[tokenCount] = st.nextToken(); tokenCount = tokenCount + 1; } //add to the sites siteList.add(new site(lineContents[0],lineContents[1])); }
Reply With Quote