Boa noite, estou com dificuldade em resolver um problema, estou tentando adicionar as informações de um arquivo txt linha por linha em um arraylist, estou usando um metodo set para adicionar e um get para recuperar as linhas do array, mas não tenho exito.
public class Documentos {
private static List<String> linhaRA = new ArrayList();
private String profissao;
public Documentos(String linhaRa){
this.linhaRA.add(linhaRa);
}
public Documentos(){
}
public static String getLinhaRA(int posicao) {
return linhaRA.get(posicao);
}
public static int getLinhaRALength(){
return linhaRA.size();
}
public void setLinhaRA(String linhaRA){
this.linhaRA.add(linhaRA);
}
public void chooser() {
Documentos documento = new Documentos();
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
try
{
FileReader arq = new FileReader(chooser.getSelectedFile());
BufferedReader lerArq = new BufferedReader(arq);
List<String> texto1 = new ArrayList<>();
String texto2;
while ((texto2 = lerArq.readLine()) != null) {
int count = 0;
documento.setLinhaRA(texto2);
System.out.println(documento.getLinhaRA(count));
count++;
}
arq.close();
lerArq.close();
}
catch (IOException localIOException) {}
}
}