java - Need help casting from a List<String[]> to an Array -


i using csvparser library univocity , having trouble converting list object in array read from.

the method keeps throwing arraystoreexception is:

list<string[]> resolveddata; string[] array = new string[7000];  public void parseurls() throws filenotfoundexception {      csvparsersettings settings = new csvparsersettings();     settings.getformat().setlineseparator("\n");     csvparser parser = new csvparser(settings);      try {         resolveddata = parser.parseall(new filereader("c:\\users\\kevin.anderson\\desktop\\book1.csv"));         resolveddata.toarray(array);     } catch (exception ex) {         system.out.println(ex.tostring());      } } 

is there way items out of list array or there easy way iterate thru items in list string array?

thank

try this.

    list<string[]> resolveddata;     string[][] array;      public void parseurls() throws filenotfoundexception {          csvparsersettings settings = new csvparsersettings();         settings.getformat().setlineseparator("\n");         csvparser parser = new csvparser(settings);          try {             resolveddata = parser.parseall(new filereader("c:\\users\\kevin.anderson\\desktop\\book1.csv"));             array = new string[resolveddata.size()][];             resolveddata.toarray(array);         } catch (exception ex) {             system.out.println(ex.tostring());         }     } 

basic errors assumed fixed size of incoming list of 7000 , single dimension array addressed with

string[][] array = new string[resolveddata.size()][];


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -