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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:09:03+00:00 2026-06-15T17:09:03+00:00

I am trying to create a text file and in that text file i

  • 0

I am trying to create a text file and in that text file i have different columns of different size and i have to write accordingly in that file,
I have tried like that …..
but I dont know how to define the size for each column for example i want the location for size 30 not less not more how can i do that ?

BufferedWriter bw = null;
    try {
        String none=" ";
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
         Date date = new Date();
         int no_of_files=01;

        String line1 = "H"+StringUtils.rightPad(none,9)+dateFormat.format(date)+StringUtils.rightPad(none,8)+" "+no_of_files+StringUtils.rightPad(none,10)+StringUtils.rightPad(none,290);
        String line2 =StringUtils.rightPad("CID",10)+StringUtils.rightPad("Location",30)+StringUtils.rightPad("DateSF",8)+StringUtils.rightPad("DateST",8)+StringUtils.rightPad("BillAmt",10)+StringUtils.rightPad("BR",2)+StringUtils.rightPad("PDF FileName",260);






        File file = new File("D:\\write.txt");


        bw = new BufferedWriter(new FileWriter(file));


        bw.write(line1);
        bw.newLine();
        bw.write(line2);
       // writer.write(line2);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (bw != null) {
                bw.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

}

  • 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-15T17:09:04+00:00Added an answer on June 15, 2026 at 5:09 pm

    I would look into using this function from Commons-IO to help keep the length of each column the same.

    StringUtils.rightPad()

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

Sidebar

Related Questions

I'm trying to create a program that takes a text file of c++ code
I'm trying to get the int value of a text file that have text
I am trying to create a text file using VB.Net with UTF8 encoding, without
Cross-post http://perlmonks.org/index.pl?node_id=979710 I'm trying to create a text file from some XML using Perl
Alright well I am trying to create a dictionary from a text file so
I am trying to implement vectorization of a text file...I have created a dictionary
I'm trying to create text in html, that once clicked, the the value of
I am trying to create a text highlight option for my website. But I
I am trying to create full text index but I am getting error which
I am trying to create a simple batch file that will replace a line

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.