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 6727379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:02:34+00:00 2026-05-26T10:02:34+00:00

I have the below requirement but am not able to decide on the approach

  • 0

I have the below requirement but am not able to decide on the approach to take:

I need to write data to a fixed format out put file where each record spans over multiple lines as seen below:

000120992599999990000000000000009291100000000000000000000000010000
000000000000000000000006050052570009700000050000990494920000111100
      ABCDE:WXYZ                                              0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
000000000000000000000006050052730005700001100000090494920000221200
      ABCDE:WXYZ                                              0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
000000000000000000000006050113110009700000000000000494920000311100
      ABCDE:WXYZ                                              0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
000012099259999999000000000000000929110000000000000000000000001000

This is one record from above example:

000000000000000000000006050052570009700000050000990494920000111100
      ABCDE:WXYZ                                              0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200
      descriptiongoesheredescriptiongoesheredescriptiongoesher0200

The first and last line are header and footer respectively.
First line of each record contains several details.
2nd line have some other details with spaces.

I have a long description field which I need to divide into 56 characters sections and append those with record’s 3rd line onwards.

So in some of the records, this may be just one line while in some it could be three lines as well.

I need guidance about how to design my itemwriter in above scenario.

Nik

  • 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-05-26T10:02:34+00:00Added an answer on May 26, 2026 at 10:02 am

    there is a multiline records writer example in the official spring-batch-samples, search for multiline.xml and MultiLineTradeItemWriter

    its basically the usual delegate principle, you just need a proper domain object with supposable a list of those 1..n intermediate lines

        public class MultiLineTradeItemWriter implements ItemWriter<Trade>, ItemStream {
    
        private FlatFileItemWriter<String> delegate;
    
        public void write(List<? extends Trade> items) throws Exception {
                    List<String> lines = new ArrayList<String>();
                  for (Trade t : items) {
                  lines.add("BEGIN");
                  lines.add("INFO," + t.getIsin() + "," + t.getCustomer());
                  lines.add("AMNT," + t.getQuantity() + "," + t.getPrice());
                  lines.add("END");
                }
                this.delegate.write(lines);
         }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an requirement where i need to fetch the form values. i'm able
I have a requirement where I need to be able to access a list
I have a client requirement of not to use an RDBMS, but instead do
I have a simple requirement as mentioned below: A ListView or any control displays
I have below sample data. AID Date Title ----- ---------- ------ 1 2011-12-12 test1
I have a requirement where I need to create a dojox.layout.ContentPane programmatically. function constructContentPane(methodToBeCalled){
I have a requirement that I have not found a solution or assistance for
I have the below jquery code I have customized it as per my requirement
We have a requirement like this. First of all this is not a AppStore
Ok, I am new to this but this is what I need. I have

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.