Displaying large file in JTextArea.
Posted
by Sathish Gopal
on Stack Overflow
See other posts from Stack Overflow
or by Sathish Gopal
Published on 2010-04-29T10:51:37Z
Indexed on
2010/04/29
10:57 UTC
Read the original article
Hit count: 379
Hi All,
I'm currently working in Swing UI Assignment. This work involves showing large file content in JTextArea. The file size can be as large as 2 GB.
My initial idea is to lazily load content from the file, say 1 MB of content will be shown to the user. As the user scrolls i will retrieve the next 1 MB of content to be shown. All these operation will be happening in background thread (Swing Worker).
I looked at the JTextArea API, the method insert takes String and int(position of the insert) as the parameter.
This will suffice, but i'm worried about performance, because the content (1 MB at a time) retrieved will have to be converted to String object.
Is there any other work around or any other alternative/better solution for this.
© Stack Overflow or respective owner