Q:

JavaFX textarea displaying big file

I'm trying to show on screen a textfile content using JavaFX textarea. I success doing it with small files, but with big ones everything becomes too slow. File with size 64KB was read in 1 second, and it takes 2 minutes to display it. There is code:
try (FileReader fileReader = new FileReader(file); BufferedReader reader = new BufferedReader(fileReader)) {
    char[] buf = new char[102400];
    int haveRead;
    while ((haveRead = reader.read(buf)) != -1) {
        buf = Arrays.copyOf(buf, haveRead);
        String str = new String(buf);
        textArea.appendText(str);
        log.trace(str);
    }
} catch (IOException e) {
    log.error("Error while reading file", e);
}

Logging shows that even with multithreading almost all time program waiting for 

textArea.appendText(str);

What to do? Is there faster implementation or mine faults in code? or the only way is to do buffer of displaying text, somehow overriding the behavior of textarea slider?

A:

Don't use TextArea when you have more than thousand lines of text.
If you want just to display the text simply use a ListView<String>:
But if you need to edit the Text you have to build your own BigTextArea or look for a good library with one. For example RichTextFx:
StyleClassedTextArea bigTextArea = new StyleClassedTextArea();
try (FileReader fileReader = new FileReader(file);
                    BufferedReader reader = new BufferedReader(fileReader)) {
    StringBuilder sb = new StringBuilder();
    while ((haveRead = reader.read(buf)) != -1) {
        sb.append(buf);
    }
    bigTextArea.appendText(sb.toString());
} catch (IOException e) {
    log.error("Error while reading file", e);
}

