Leitura apenas da ultima linha

1 resposta
M

Boa tarde,

o código abaixo mostra apenas a ultima linha do arquivo txt., já tentei mas não consegui.

Alguém poderia me ajudar?

try {
			File arquivo = new File("BancoDeDados.txt");
			 
			 FileInputStream in = new FileInputStream(arquivo);
			 InputStreamReader conversor = new InputStreamReader(in);
			 BufferedReader bf = new BufferedReader(conversor);
			 boolean continua=true; 
			
			 String linha = bf.readLine();
			 
			 while ((linha=bf.readLine())!=null){  
				 
				 
				aq.setText("");
				 aq.append(linha.toString());
				
			 
			
			 }
			 bf.close();
			 in.close(); 
			} catch (IOException e) {
				System.err.printf("Erro na abertura do arquivo: %s.\n",
				          e.getMessage());
			}
				}}
			}

Obrigado

1 Resposta

ViniGodoy

Mova a linha 14 para antes do while.

Criado 29 de junho de 2014
Ultima resposta 29 de jun. de 2014
Respostas 1
Participantes 2