CRLF and LF in MuleSoft
How we can acheive CRLF and LF using MuleSoft in Notepad ++
CRLF: The term CRLF refers to Carriage Return (ASCII 13, \r ) Line Feed (ASCII 10, \n ). They’re used to note the termination of a line, however, dealt with differently in today’s popular Operating Systems.
LF: Line Feed (\n
, 0x0A
in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.
Use-Case:
- When we write a particular file in any location in our local system using MuleSoft and open in notepad ++.
- So, when we open a file in notepadd ++. There is show all character in Notepadd ++ where you can see either CRLF or LF.
- Example: Suppose in file There are 100 records first 99 records should come as CRLF and last record as LF.
- In mule pallete take Write Connector and give the configuration path and in write mode should be APPEND according to use case.
5. How we can acheive CRLF and LF in MuleSoft. So take TM and write logic as below.
output application/csv separator=”|” ,lineSeparator= “\r\n”
6. Take Set Payload Connector and give MIME Type text/plain.
7. Now, take TM and write the logic as below.
((payload)[0 to -3] ) ++ “\n”
8. In this logic [0 to -3] in this “\r\n” in initially I am deleting this in the TM and then, just doing appending the value “\n” in the next TM.
9. In Postman, Just sending the body in the JSON Format in POST Method done the configuration accordingly.
10. Now, File is written to the particular location in the local system.
11. Open the file with notepadd ++ and click on show all character. The highlight part is show as below in screenshot.
12. The Final Output or response using MuleSot in the notepadd ++ looks in the below screenshot.
Conclusion:
By using above ssteps in MuleSoft we can achive CRLF and LF in MuleSoft.
References: