I have a text file with the following format(the words at each line are seperated with tab):
stri1   stri2   stri3
stri4   stri5   stri6
stri7   stri8
stri9   stri0   stri5
As you can see i have some lines with only two words. I have a class to save the words of each line:
public class Entity{
   private word1,word2,word3;
   
   //constructor and getter/setter methods
}
I want to save the text values using the following code:
for(String i : filelines){
   String[] line = i.split("\t");
   if(line[2] == null){
      listOfEntities.add(new Entity(line[0], line[1], null));
   }
   else{
      listOfEntities.add(new Entity(line[0], line[1], line[2]));
}
When i try to execute this code i get an ArrayIndexOutOfBoundsException because some line have only 2 words. How can i handle this situation because i want also the null values in order to make some sql queries later.
 
     
     
    