0

I am taking in CSV files from Nasdaq and am using Apache Commons CSV to parse it. For some reason I am getting a NullPointerException and I can't seem to figure out why.

These are my lines where I create the reader and parser

data = new URL("http://www.nasdaq.com/screening/companies-by-industry.aspx?industry=Health%20Care&render=download");
Reader dataReader= new InputStreamReader(new BOMInputStream(data.openStream()), "UTF-8");
CSVParser dataParse= new CSVParser(dataReader, CSVFormat.EXCEL.withHeader());

I am then adding to an ArrayList to store the values:

for (final CSVRecord record : dataParse) {
    myArrayList.add(new MyClass(record.get("Symbol"),         
    record.get("Industry")));
}

It seems to me like the CSV file is fine, so not sure why this would be happening. Thanks

j1nrg
  • 69
  • 7
  • 1
    Add the error stacktrace. – Alfabravo May 06 '16 at 21:45
  • try breaking the three lines of code into their own (separate) lines and see where the NPE is being thrown. Without a full stack trace is impossible to tell from here. Hint: use a debugger for faster results – blurfus May 06 '16 at 21:46
  • The first three lines I included are where the error is occurring – j1nrg May 06 '16 at 21:47
  • sure, but which one? each line has 3 or 4 potential sources of the NPE. If you break it into separate lines, it's easier to tell which one is the source. and what about that stacktrace? – blurfus May 06 '16 at 21:48

0 Answers0