-3

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..

Garry Steve
  • 129
  • 2
  • 11

2 Answers2

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