Grazie mille per l'aiuto! Ho provato a fare come mi hai detto e il risultato è questo:
ArrayList<Utente> utenti = new ArrayList<Utente>();
public void setUtente() {
try {
BufferedReader in = new BufferedReader(new FileReader("inputFile.txt"));
String str;
while ((str = in.readLine()) != null) {
String[] strings=str.split(" ");
String id=strings[0];
String password=strings[1];
String nome=strings[2];
String cognome=strings[3];
Utente u = new Utente();
u.setId(id);
u.setPassword(password);
u.setNome(nome);
u.setCognome(cognome);
utenti.add(u);
}
in.close();
} catch (Exception e) {
System.err.println("Non ho aperto il file");
}
}
Dove i metodi set sono del tipo:
public void setNome(String nome) {
this.nome = nome;
}
Purtroppo quando eseguo il programma mi restituisce "Non ho aperto il file"