I have a program that pretends to be a Contacts Diary, the problem is that adding more data to ArrayList
the program does not work for me:
public ArrayList<modeloPersona> LeerTodoArchivo(String Archivo){
ArrayList<modeloPersona> personaArreglo = new ArrayList<modeloPersona>();
modeloPersona persona;
try {
File file = new File(Archivo);
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
String linea;
while ((linea = bufferedReader.readLine()) != null) {
String[] partes = linea.split(",");
persona = new modeloPersona();//SE CONSTRUYE
persona.setNombre(partes[0]);
persona.setTelefono(partes[1]);
persona.setDireccion(partes[2]);
// persona.setEdad(partes[3]);
// persona.setComentario(partes[4]);
personaArreglo.add(persona);
}
fileReader.close();
} catch (IOException e) {
e.printStackTrace();
}
return personaArreglo;
}
The problem is that when you add, for example, a:
persona.setEdad(partes[3]);
and persona.setComentario(partes[4]);
It does not leave me, it only lets me have three positions from 0 to 2.
Show me the error
ArrayIndexOutOfBoundsException