javacsvbindy

Remove all new lines and make single line with n character


Generating CSV. I am trying to create a single string of description which has multiple next line.

I tried :

description = a.replaceAll("\n","\\\\n");

But I got \n and it does not come in one line

Current Output

IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com
\n
\nAll users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers. 
\n
\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups. 
\n
\nNew groups are created by requesting a group from My Support, there is no self-service for that.

Expecting:

IS0001;10381;Active Directory groups EU AD;SW;Internal applications;E\CIERORAD;CRP\E616053;16053;616053;radva.cierny@evry.com;E\XXJANDAM;CRP\E21494;7481;21494;ext.milsv.janda@evry.com;This tool allows users to view and manage delivery lists and groups in Active Directory. Everyone in EVRY will have access via https://int.eto.com \n\n All users can view the distribution lists and security groups they are members of, with the exception of dynamic distribution lists. Dynamic distribution lists are based on Wo/ERP data, and they are usually for organizational units and some roles, e.g. line managers. \n\nGroup owners can view and manage their groups, including renewing and deleting groups, and adding and removing members of these groups. \n\nNew groups are created by requesting a group from My Support, there is no self-service for that.

Any idea how to make it in one line?


Solution

  • Achieved using

    description = a.replace("\n", "\\\\n").replace("\r", "");