I tell you, I have a problem reading the new line ("\n") in some files that are generated dynamically with Java.
I'll tell you a bit about the structure above since I can't paste all the code because there are so many lines in several files:
I have a
String variable = generarFichero();
The generateFichero() function in turn has:
String parte1 = generaParteUno();
String parte2 = generaParteDos();
String otraCosa = "Loquesea";
return otraCosa.concat(parte1).concat(parte2).concat("\n");
The thing is that in the end there should be a file whose content was more or less like this: (Imagine that the hyphens are spaces)
Test1----------Data1---------Data2
Test2----------Data1---------Data2
Test3----------Data1---------Data2
Do you understand me?
Well, if I open it with a Linux text editor or with a Windows style Notepad++, Sublime etc. it looks correctly without problems, but in the notepad because it's from Windows or not it doesn't look like that, it looks without the new lines, I don't know if I'm explaining myself.
Well, the problem is that later that file is sent automatically and what processes that file gives an error because it reads it the way I explained before, without line breaks, I don't know if I can use something more "universal" than the \n for create it or if there is any way to do it right.
Thank you very much in advance!
instead of:
Try like this:
I hope it works for you, regards
You can use
System.lineSeparator()
which sets the appropriate line break for the system.Font
Since you haven't included part of the code. Assuming you are generating the documents with the BufferedWriter function, you should use the new line method as this will generate a line break in the file, while "\n" is just a format that notepad doesn't recognize.
If you use BufferedWriter, you should add this line between file:
BufferedWriter bw;