Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8124333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:25:49+00:00 2026-06-06T06:25:49+00:00

I have an Item Writer as below: <beans:property name=lineAggregator> <beans:bean class=org.springframework.batch.item.file.transform.FormatterLineAggregator> <beans:property name=fieldExtractor> <beans:bean

  • 0

I have an Item Writer as below:

<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator">
        <beans:property name="fieldExtractor">
                <beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
                 <beans:property name="names" value="column1, column2, column3, column4 " /> 
                </beans:bean>
            </beans:property>

            <beans:property name="format" value="%-8s%-12s%-11s%-16s" /> 
        </beans:bean>
    </beans:property>

As clear, I am writing 4 columns to a fixed format file with column lengths as 8, 12, 11 and 16 respectively.

However, say column 1 string is 14 characters instead of 8 characters, then the output file is blindly accomodating all the 14 characters by pushing the whole line ahead.

THIS IS A TEST

Expecting: 
THIS IS COL2STARTS

Getting: 
THIS IS A TESTCOL2STARTS

How to avoid this ?

Shouldn’t the remaining characters get truncated and only the first 8 characters written ?

Do I need to put in validation in my code to strictly pass only 8 characters as expected by column ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:25:50+00:00Added an answer on June 6, 2026 at 6:25 am

    You have to set the precision along with the width. Try this formatter String:

    <beans:property name="format" value="%-8.8s%-12.12s%-11.11s%-16.16s" /> 
    

    See: FormatterLineAggregator, Formatter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a db to file job. The item writer is as below: <beans:bean
I have that situation: I have models Item, Region and Country. class Item(models.Model): name
I have a spring batch program where I am implementing skiplistener class as below:
I have the following writer configured in my beans definition file of a spring
I have one custom config file. <Students> <student> <Detail Name=abc Class=1st Year> <add key=Main
I have an item that when hovering in IE7 is causing the item below
I have a model item public class EntryInputModel { ... [Required(ErrorMessage = Description is
I have created a spring-batch job. My reader class reads the data from the
I have this item renderer MyRenderer.mxml <?xml version=1.0 encoding=utf-8?> <mx:HBox xmlns:mx=http://www.adobe.com/2006/mxml implements=mx.core.IDataRenderer > <mx:Script>
We have an item cull that retrieves items and their appropriate data from one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.