2
JTextArea caixaTexto = new JTextArea();
try {
String[] arrayLinhas = null;
int i = 0;
BufferedReader br = new BufferedReader(new FileReader(diretoriaExecucao + "/" + valorSelecionado));
while(br.ready()){
String linha = br.readLine();
arrayLinhas[i] = linha;
i++;
}
caixaTexto.setText(arrayLinhas.toString()); //imprimo caixa texto
br.close();
} catch (IOException e2) {
e2.printStackTrace();
}
I have a list from which I select a file, read that file and print the output in the Jtextarea text box.
Gives me an error of null Exception on line:
arrayLines[i] = line;
Yes but now I have the problem when I write in the text box with the first solution does not show me the text but encoded.
– rrr
That’s another problem, young man. You can open another question with this.
– Jéf Bueno
may be List instead of List array?
– rrr
On the left side (declaration) yes, on the right side (instantiation).
– Jéf Bueno
In the case of append no, this is because every time you click on other files, the text that is already there always appears.
– rrr
Clean it up first, pray. I edited the answer
– Jéf Bueno
and how do I change line? /n does not work
– rrr
and vote on my post pff to mark you correct answer
– rrr
It’s all right, man.
– Jéf Bueno