I want the textarea show the content of a file txt. Here is my code, it just shows the last line of the text, I know the problem is ta1.settext()
. Can someone pls give me some advice?
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource() == btnOK) {
String link = tf1.getText().toString();
try(BufferedReader br = new BufferedReader(new FileReader(link)))
{
String line;
while((line = br.readLine()) != null) {
ta1.setText(line);
}
br.close();
}
all the line of the file The last line