Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>JTextPane/JEditorPane do not handle well even 1mb of text (especially text with long lines).</p> <p>You can try JEdit (<a href="http://www.jedit.org/api/org/gjt/sp/jedit/textarea/StandaloneTextArea.html" rel="nofollow">StandaloneTextArea</a>) - it is much faster than Swing text components, but I doubt it will handle this much text. I tried with 45m file, and while it was loaded (~25 seconds) and I could scroll down, I started getting "outofmemory" with 1700m heap.</p> <p>In order to build a really scalable solution there are two obvious options really:</p> <ol> <li><p>Use pagination. You can do just fine with standard Swing by displaying text in pages.</p></li> <li><p>Build a custom text renderer. It can be as simple as a scrollable pane where only the visible part is drawn using <a href="http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html" rel="nofollow">BufferedReader</a> to skip to the desired line in the file and read a limited number of lines to display. I did it before and it is a workable solution. If you need to have 'text selection' capabilities, this is a little more work, of course.</p></li> </ol> <p>For really large files you could build an index file that contains offsets of each line in characters, so getting the "offset" is a quick "<a href="http://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html" rel="nofollow">RandomAccess</a>" lookup by line number, and reading the text is a "<a href="http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html#skip%28long%29" rel="nofollow">skip</a>" with this offset. Very large files can be viewed with this technique.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload