Results 1 to 3 of 3

Thread: LineSeparator

  1. #1
    Join Date
    Apr 2009
    Posts
    5

    Default LineSeparator

    I am trying to use the lineSeparator property from the FlatFileItemWriter class.
    I need to have a return line after each row regardless of the execution platform. I am using Spring Batch 2.0.1 I tried \r\n then \r then \n but when i open the file it has the values in the file.

    Example:
    01 013 013 105 013 1 \n01

    here is my code:

    Code:
    <beans:bean id="courseWriter" class="org.springframework.batch.item.file.FlatFileItemWriter">
    		<beans:property name="resource" value="file:/tmp/course.txt" />
    		<beans:property name="lineSeparator" value="\r\n" />
    		<beans:property name="shouldDeleteIfExists" value="true" />
            <beans:property name="lineAggregator">
                <beans:bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator">
                    <beans:property name="fieldExtractor">
                        <beans:bean class="edu.rutgers.enterprise.fyss.batch.MapFieldExtractor">
                            <beans:property name="names" value="faculty,dept,name,subject,active,descript"/>
                        </beans:bean>
                    </beans:property>
                    <beans:property name="format" value="%-30s%-30s%-30s%-30s%-1s%-35s"/>
                </beans:bean>
            </beans:property>
    	</beans:bean>

  2. #2
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    XML literals are not the same as Java literals. You can use a static constant in a Java class and get a reference to it in the config file using <util:constant/>. Or you can define an enitity in the XML, or maybe use existing standard XML entities.

  3. #3
    Join Date
    Apr 2009
    Posts
    5

    Default

    Dave,
    I used existing standard XML entities and now it works correctly.

    <beans: property name="lineSeparator" value="&#xD;&#xA;" />

    Thanks,

    - Ed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •