View large file in JTextArea

I am currently working in Swing UI Assignment. This work involves displaying large file contents in JTextArea. File size can reach 2 GB.

My initial idea is lazy loading content from a file, say, 1 MB of content will be displayed to the user. As the user scrolls, I get the next 1 MB of content to be shown. All these operations will be performed in the background thread (Swing Worker).

I looked at the JTextArea API, inserting a method as a parameter takes String and int (insert position).

This is enough, but I'm worried about performance, because the extracted content (1 MB at a time) must be converted to a String object.

Is there any other work or any other alternative / best solution for this.

+3
source share
1 answer

The issue of efficiency will be the model of the document.

Likely to provide an effective implementation Document.

However, I personally would try to review and try using a different user interface. Who could scroll 2 GB of data anyway?

+4
source

Source: https://habr.com/ru/post/1743331/


All Articles