Pregunta

I am creating a simple Notepad which reads text file,saves them and few common operation

My problem is that when it reads the file (a source code), it shows the whole code in one line , no line feed is followed. (new line is not detected, tab is detected

I am currently using BufferedReader with FileReader in JTextArea. enter image description hereAny suggestions ?

¿Fue útil?

Solución

My guess is that you expect BufferedReader.readLine() to return the line, including its ending EOL character sequence. That's not the case. readLine() returns the line without its ending line break. So you need to explicitely append a newline to the text area:

textArea.append(line);
textArea.append("\n");

Otros consejos

Please show us how are you using BufferedReader.

You can use bufferedReader.readLine() instead of bufferedReader.read(). Please note you should add new line manually in this case.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top