I have problem with this annoying ^M, while exporting some data, writing it to a CSV file to be downloaded. I did some research and found out that if the file you are reading comes from a Windows system this issue happens (Windows uses CR (i.e. ^M)/LF pair to indicate the end of a line, while UNIX uses only a LF).
Now can anyone offer me a solution to overcome this problem (like eliminating or replacing ^M ) before putting it to the writer (writer.write(columnToBeInserted);)
You could use
unix2dosanddos2unixto convert UNIX and Windows files respectively. Both are available on *nix and Windows platforms. Read more.Links for Windows
Dos2Unix
Unix2Dos
Also see How to convert files from Dos to Unix in java