Search code examples
newlinebean-io

Force CRLF on BeanIo Export


I want to force BeanIO to use CRLF as terminator when exporting a fixed-length stream. The following does not work

<stream name="marketFeed" format="fixedlength">
        <parser>
            <property name="recordTerminator" value="CRLF" />
        </parser>

I want to be tolerant for line-endings on parse, but want to use CRLF on export. This is in fact an I/O stream format.

Is this possible?


Solution

  • Have you tried:

    <stream name="marketFeed" format="fixedlength">
        <parser>
            <property name="recordTerminator" value="\r\n" />
        </parser>
    

    OR if it has to be escaped:

    <stream name="marketFeed" format="fixedlength">
        <parser>
            <property name="recordTerminator" value="\\r\\n" />
        </parser>
    

    CR usually implies \r and LF = \n. I haven't tested this though.

    [OP comment]: no need to escape