I'm experiencing a problem using StringTokenizers. For some reason, I'm getting a NullPointerException thrown, which is odd because in other parts of my code where simular code is being executed, such problems are not popping up.
What is happening in this example is, that a line is being read that holds 3 scores for a game. The line would look like this: "|9|13|63 " The String is tokenized, and then stored into an ArrayList.
Here's an example of what's happening:
StringTokenizer st; String strTemp;
strTemp = in.readLine(); //Reads next line st = new StringTokenizer(strTemp, "|"); //Tokenizes current line while(st.hasMoreTokens()) { scoreArray.add(st.nextToken()); //adds the tokenized string to an ArrayList }
The NullPointerException occurs Right at the line: scoreArray.add(st.nextToken());