I need to deal with a 3-line file with the following structure:
nome
data
horário
To read this method I use the following commands:
BufferedReader leitor = new BufferedReader(new FileReader("dados/dados.txt"));
ArrayList<String> dados = new ArrayList<>();
String linha = "";
while((linha = leitor.readLine()) != null){
dados.add(linha);
}
leitor.close();
But at the end of the reading, the first line of the file gets corrupted with the value null
, when in fact it was to continue with the value of the name field.
How can I read the file without corrupting it?