I am using openCSV to generate .txt file. I am able to generate the file successfully, but the new line character which i have given were not reflecting in the notepad. But when open the same file in notepad++ it is working fine. Is there any approach to make it work in the notepad..
Asked
Active
Viewed 4,040 times
-3
-
what eol char are you using? generated on linux and displayed on windows? – Scary Wombat Nov 29 '17 at 04:40
-
1No generated in windows only. generated with openCSV using java. – Garry Steve Nov 29 '17 at 04:49
-
set the eol char using http://opencsv.sourceforge.net/apidocs/com/opencsv/CSVWriter.html#CSVWriter(java.io.Writer,%20char,%20char,%20char,%20java.lang.String) – Scary Wombat Nov 29 '17 at 04:55
-
Windows notepad DOES NOT recognize Unix line endings. It is a Windows only program. – Jim Garrison Nov 29 '17 at 05:05
2 Answers
1
Windows notepad is a Windows-only program that expects \r\n
for line endings. It does not recognize Unix-style line endings \n
, and will never do so, and cannot be made to do so.
Do not use Windows notepad to open Unix/Linux style files.

Jim Garrison
- 85,615
- 20
- 155
- 190
0
One option is to first open the generated file in Notepad++ and search for the regular expression
(?!\r)(.)\n
And replace it with
$1\r\n
Then save the file and open it in Windows notepad.
Another option is to use \r\n as your new line character when you generate the file, if that is an option in your particular situation.

Josh Withee
- 9,922
- 3
- 44
- 62