Android Java newline not working
I'm having one of my apps output to a text file for saves. To do this I'm just using some code I've used before--a FileWriter that outputs String + "|" + String + "\n".
Everything works fine except for the newline char, "\n"--it's just skip and the program moves on开发者_开发技巧 to the next string without starting a new lin. I've tried doing html (<br />
) instead, but that just prints out <br />
. What am I missing?
Ok, problem solved. "\r\n". Strange, "\n" works just fine on its own for all my other programs, but I'm guessing it has something to do with the environment. Thanks Sam!
As you've worked out, Notepad doesn't handle Unix style line termination.
Wordpad, however, does, so you could try viewing the text file in Wordpad if it's important to use Unix style line termination (you're running on Unix, so why wouldn't you? :-) )
Try doing this, create a string, then have it have the entire .txt as it, then shoot the file in the FOS
String output = "|" + string + "\n";
then just keep adding to it, then put that string in as it, because the string will become multiline and just print out into the file the same way
精彩评论