BufferedReader.readLine
removes the line breaks. Just add the line breaks back in and use a TextArea
:
StringBuilder stringBuilder = new StringBuilder();
String text;
while ((text = bufferedReader.readLine()) != null) {
stringBuilder.append(text).append("\n");
}
// set the text in the TextArea
your_text_area.setText(stringBuilder.toString());
A TextArea
breaks lines that are too wide, but adds a ScrollBar if the content gets too high for the container (does not resize vertically normaly).
Alternatively you can to use javafx.scene.text.Text
. Text
resizes to the content size by default.