在Spring Batch上从文件中跳过页眉,正文和页脚行 [英] Skip header, body and footer lines from file on Spring Batch

查看:88
本文介绍了在Spring Batch上从文件中跳过页眉,正文和页脚行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个专门的文件:

H;COD;CREATION_DATE;TOT_POR;TYPE
H;001;2013-10-30;20;R
D;DETAIL_VALUE;PROP_VALUE
D;003;3030
D;002;3031
D;005;3032
T;NUM_FOL;TOT
T;1;503.45

如您所见,它具有页眉/正文/页脚行.我正在寻找跳过这些行的ItemReader.我已经在下面使用 PatternMatchingCompositeLineMapper 来识别这些行的ItemReader.

As you can see, it has header/body/footer lines. I'm looking for a ItemReader that skip these lines. I've done this ItemReader below who identify those lines, using PatternMatchingCompositeLineMapper.

<bean id="fileReader" class="org.springframework.batch.item.file.FlatFileItemReader">
        <property name="resource" ref="myFileReference" />
        <property name="lineMapper">
            <bean class="org.springframework.batch.item.file.mapping.PatternMatchingCompositeLineMapper">
                <property name="tokenizers">
                    <map>
                        <entry key="H*" value-ref="headerLineTokenizer"/>
                        <entry key="D*" value-ref="bodyLineTokenizer"/>
                        <entry key="T*" value-ref="footerLineTokenizer"/>
                    </map>
                </property>
                <property name="fieldSetMappers">
                    <map>
                        <entry key="H*" value-ref="headerMapper"/>
                        <entry key="D*" value-ref="bodyMapper"/>
                        <entry key="T*" value-ref="footerMapper"/>
                    </map>
                </property>
            </bean>
        </property>
    </bean>

我试图添加linesToSkip属性等于1,但它只跳过了标题行.有没有一种方法可以跳过每个块的第一行(页眉,正文和页脚)?

I tried to add linesToSkip property equals 1, but it only skipped the header line. Is there a way to skip the first line of each block(header, body and footer)?

谢谢.

推荐答案

不是. linesToSkip(如您所写)只需跳过前linesToSkip行.
您必须使用 multiorder编写自己的阅读器行示例(或

Nope. linesToSkip (as you wrote) just skip the first linesToSkip lines.
You have to write your own reader using multiorder-line example (or this post) as base and manage skip first line of each block manually

这篇关于在Spring Batch上从文件中跳过页眉,正文和页脚行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆