Olá, recentemente fiz um post para tirar dúvidas sobre ler arquivos de .txt dentro do jTextArea.
Está funcionando normalmente, abre o arquivo completo e tudo mais… Porém o txt que estou tentando abrir é pesado chega ser por volta dos 4MB o arquivo de texto e demora uns 5 min para abrir o arquivo no jTxtArea.
Arquivo .txt para fazerem teste: https://drive.google.com/open?id=1y-NYklDUrILaYaRwz2I3_MHqVYqvIrad
A questão é, ele demora um pouco mesmo para carregar o arquivo ou estou fazendo isso errado? Vou postar o código rsrs
public void buscar(){
String texto="";
FileNameExtensionFilter fileNameExtensionFilter = new FileNameExtensionFilter(
"txt", "txt");
JFileChooser fc = new JFileChooser();
fc.setFileFilter(fileNameExtensionFilter);
fc.setDialogTitle("Escolha o arquivo");
int resposta = fc.showOpenDialog(null);
if(resposta == JFileChooser.APPROVE_OPTION){
File file = new File(fc.getSelectedFile().getAbsolutePath());
FileReader fis;
try {
fis = new FileReader(file);
caminho=file.toString();
jTextField1.setText(file.toString());
jTextField1.setEditable(false);
BufferedReader bis = new BufferedReader(fis);
while(bis.ready()){
//System.out.println(bis.readLine()+"\n");
texto=texto+bis.readLine()+"\n";
}
jTextArea1.setText(texto);
bis.close();
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
}
}