Announcement Announcement Module
Collapse
No announcement yet.
LineSeparator Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


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

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

      Thanks,

      - Ed

      Comment

      Working...
      X