Skip to content

Empty file check support

Summer.Batch.Extra.EmptyCheckSupport.EmptyFileCheckTasklet is dedicated to check if a given file is empty or not. It returns an ExitStatus "EMPTY" if the file is empty or absent, "NOT_EMPTY" if it exists and is not empty.

The only mandatory property is FileToCheck; it points at the target file resource to be checked for existence/emptiness.

Configuring the EmptyFileCheckTasklet in the job XML file:

Example 7.14. Typical EmptyFileCheckTasklet usage in the job XML file

<step id="S01_EmptyFileCheck">
    <batchlet ref="S01_EmptyFileCheckBatchlet" />
    <next on="NOT_EMPTY" to="S02_Writer" />
    <next on="EMPTY" to="S03_Writer" />
<step id="S02_Writer" next="S03_Writer">
    <chunk item-count="1000">
        <reader ref="S02_Writer/Reader" />
        <writer ref="S02_Writer/Writer" />
<step id="S03_Writer">
    <chunk item-count="1000">
        <reader ref="S03_Writer/Reader" />
        <writer ref="S03_Writer/Writer" />


Recommendation: Usage should use of the returned ExitStatus as a switch to organize the job execution flow, as demonstrated by the example above.

Example 7.15. Sample Unity configuration for a EmptyFileCheckTasklet

// Step S01_EmptyFileCheck - Empty file check step
private void RegisterS01_EmptyFileCheckTasklet(IUnityContainer container)