Handling large text files with JTextPane
Posted on 2004-04-07
Is there a restriction concerning the size of (text) files when trying to display them in a JTextPane?
I have trace files which can have a size of 10MB, 20MB, or even 100MB and when I try to display the files content within a JTextPane I get an OutOfMemoryError. How can I handle this best?
By now I just read the file's content with a BufferedReader into a StringBuffer to display the StringBuffer's content within a JTextPane. On later stages I want to group the source file's content and display these groups in different JTextPanes.
The error occurs when executing this statement:
this.replaceSelection(sb + "\n");
(Where 'sb' is the StringBuffer instance obviuosly).
How can I avoid getting this OutOfMemoryError?