how to load array of strings with loadString

This file.txt contains:

"filename","5020","bw","10" "filename2","2048","bw","11" "filename3","1024","wb","12"

String address[]=loadStrings("file.txt");

prints to console:


I want to create a 2D array where



But can't figure out sytntax to get list[][]=split(address[0-3],',') to put elements in array

String list[]=split(address[0],','); works for one line of address
but can't get the 2D array to read in
Tryed String list[][]=split(address[0-2],',') in for loop but get
can't convert String[] to String[][]

thanks for any help


  • whats the difference between String [] list and String list[] or String [][] list and String list[][]?

  • ok, got loaded string in to String list[] with split(file[i],',') then in array of [10][4] 10 lists of 4 items per index in array Now wanna convert select strings to int and tryed strthresh=fileitem[i][1].substring(0,2); and get null pointer error!

  • have array of strings list[10][4] list[0][1]="10%" want just the "10" so list[0][1].substring(0,2) should give "10" but get null pointer error!

  • Answer ✓

    Since it seems a ".csv" file, why don't you simply use loadTable() in place of loadStrings()?

  • I got it working except for string to int conversion strthresh="10" This print(strthresh) prints "10" But... thresh=int(strthresh) thresh=parseInt(strthresh) thresh=Integer.parseInt(strthresh) All the above give 0 valuse for thresh!

  • I got it. substring was 0,2 needed to be 1,3 never mind

Sign In or Register to comment.