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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:21:03+00:00 2026-06-02T23:21:03+00:00

I am reading records from file and inserting into database. I am using DB2

  • 0

I am reading records from file and inserting into database.

I am using DB2 database.

The records is like:

   abc    pqr  abcd

So before abc there are several spaces as well at the start of the record.

I am reading the file using SpringBatch program and inside field set mapper I am printing the string read from the file:

System.out.println("*" + fieldSet.readString("FULL_RECORD") + "*");

However, the result I am getting is:

*abc    pqr  abcd*

Which means that the leading spaces are not getting preserved.

The linetokenizer in my config file is:

<beans:property name="lineTokenizer">
  <beans:bean class="org.springframework.batch.item.file.transform.FixedLengthTokenizer">
    <beans:property name="columns" value="1-241"/>
    <beans:property name="names" value="FULL_RECORD"/>
  </beans:bean>
</beans:property>

I am using default line mapper class and passing above tokenizer as its property.

org.springframework.batch.item.file.mapping.DefaultLineMapper

How to preserve the leading spaces before each record?

  • 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-02T23:21:04+00:00Added an answer on June 2, 2026 at 11:21 pm

    take a look at the code

    1. the readString methods of the DefaultFieldset use
    2. String.trim()

    just change

    System.out.println("*" + fieldSet.readString("FULL_RECORD") + "*");
    

    too

    System.out.println("*" + fieldSet.readRawString("FULL_RECORD") + "*");
    

    see DefaultFieldSet.readRawString()

    Read the String value from column with given ‘name’ including trailing
    whitespace (don’t trim).

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

Sidebar

Related Questions

I'm reading positional records from a text file, for examle, it looks like this:
i am reading records data from a file(records count can be up to thousands
How do I put the records from the random access file DATA.data into the
I need to import data from a file into a Microsoft SQL Server database.
Is it possible to load records from a file straight into a hash please?
I'm reading sector-aligned chunks from a file using ReadFileEx (opened with CreateFile and the
I am having trouble reading data from a file into a list in a
Team, I am doing a technical poc for reading records from a flat file
I am reading a text file and processing some records, a relevant sample of
Ok, so I'm reading a binary file into a char array I've allocated with

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.