I read a file and set the text(about 4000KB of size) into a JTextArea. It freezes my application. Following is my code snippet. I appreciate your suggestions....
public void setText(final JTextArea textArea)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
BufferedReader from = null;
try
{
from = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
System.out.println("Started..........");
textArea.read(from, file.getName());
System.out.println("Completed..........");
}
catch (Exception ex)
{
Logger.getLogger(FileTools.class.getName()).log(Level.SEVERE, null, ex);
}
finally
{
try
{
from.close();
}
catch (IOException ex)
{
Logger.getLogger(FileTools.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
}