java - ArrayList<String> Error -


hi having 1 error bugging me!!

what trying split text file use ";"

and after store arraylist, error keeps popping up!!

package au.edu.canberra.g30813706;  import java.io.bufferedreader; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.ioexception; import java.io.inputstreamreader; import java.util.arraylist; import android.app.activity; import android.os.environment; import android.widget.edittext;   public class filereader extends activity{{      arraylist<string> sinfo = new arraylist<string>();      string txtname = "accomodationtxt.txt";     file root = environment.getexternalstoragedirectory();     file path = new file(root, "canberratourism/" + txtname);      try {          bufferedreader br = new bufferedreader (                             new inputstreamreader(                             new fileinputstream(path)));         string line;         string[] salineelements;         while ((line = br.readline()) != null)         {             //the information split segments , stored array             salineelements = line.split(";");             sinfo.add(salineelements[0], salineelements[1], salineelements[2], salineelements[3], salineelements[4]);          }          br.close();       }      catch (filenotfoundexception e) {          system.err.println("filenotfoundexception: " + e.getmessage());     }}  } 

error:

the method add(int, string) in type arraylist<string> not applicable arguments (string, string, string, string, string) 

you cannot use add method add multiple elements. you'll need use addall. this:

list<string> list = new arraylist<string>(); list.addall(arrays.aslist(salineelements[0], salineelements[1])); 

using addall can add collection of strings list.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -