Hi All,
I've created an Object that holds two Strings, myObject. I have created and array of myObject and I am trying to parse some .csv data into it using a StringTokenizer however I keep getting a null pointer exception.
If I treat myObject as a simple Object and not as an array everything works ok.
PLEASE HELP.
Steve
P.S. I'm new to this forum, please excuse me if I've copied too much of my code into this query
import java.io.IOException; import java.util.StringTokenizer; public class ForexAnalyzer { public static void main (String args[])throws IOException { FileArrayProvider bulkReader = new FileArrayProvider(); String[] rawData = bulkReader.readLines("src/EURUSD602.csv"); myObject[] parsedData = new myObject[bulkReader.getLength()]; StringTokenizer token = null; for (int i=0; i<bulkReader.getLength(); i++){ token = new StringTokenizer(rawData[i], ","); while (token.hasMoreTokens()){ parsedData[i].setDate(token.nextToken()); parsedData[i].setTime(token.nextToken()); System.out.println("Element # " + i + " Date is " + parsedData[i].getDate() + " Time is " + parsedData[i].getTime()); } } } } class myObject { private String date; private String time; //Variable set public void setDate(String inputDate){ date = inputDate; } public void setTime(String inputTime){ time = inputTime; } //Variable get public String getDate(){ return date; } public String getTime(){ return time; } }