Android Newline not working

I have one of my applications outputting a text file for saving. For this, I just use the code I used before - FileWriter, which displays String + "|" + String + "\ n".

Everything works fine, except for the new char line, "\ n" is just a skip, and the program moves on to the next line without starting a new lin. I tried to do html ( <br /> ) instead, but it just prints <br /> . What am I missing?

+4
source share
3 answers

Ok, the problem is resolved. "\ R \ n". Strange, "\ n" works fine on its own for all my other programs, but I guess this has something to do with the environment. Thanks to Sam!

+2
source

As you've already figured out, Notepad does not handle Unix-style line endings.

Wordpad, however, does this, so you can try viewing the text file in Wordpad if it is important to use a Unix-style line ending (you work on Unix, so why not? :-))

+1
source

Try this, create a line, and then save the entire .txt file, then run the file in FOS

 String output = "|" + string + "\n"; 

and then just add to it, and then put that line in it, because the line will become multi-line and just print to the file in the same way

0
source

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


All Articles