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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:21:56+00:00 2026-05-26T18:21:56+00:00

I am using a text file that stores 3 columns of data, each having

  • 0

I am using a text file that stores 3 columns of data, each having varying length.

This is the following code I have tried so far. I want each column to be left justified. For some reason it works if I use an asterisk and not if I try to manually insert a whitespace.

(line is reading in 3 words from my text file)

Attempt #2:

while((line = buf.readLine())!= null){

    StringTokenizer st = new StringTokenizer(line);

    int length = 12;

    a = st.nextToken();
    while (a.length() <= length)
    {
        a = a + "*";
    }
    b = st.nextToken();

    while (b.length() <= length)
    {
       b = b + "*";
    }
    c = st.nextToken();

    text.append(a + b + c + '\n');
}

This was my original attempt but this did not work either:
text.append(String.format(“%-15s\t %-10s\t %-5s\t \n”, a, b, c));

Any ideas would be greatly appreciated.

  • 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-26T18:21:56+00:00Added an answer on May 26, 2026 at 6:21 pm

    The key here is not to use just a single TextView for your three columns. You want to use a different TextView for each column and the control the formatting of each TextView individually. What type of layout are you using? If you switch to a table layout, it should be easy to left justify what ever you want. If your file will have a variable length, use a ListView which has three different text views in each row and then left justify each textview.

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

Sidebar

Related Questions

We have some C# code that reads data from a text file using a
I have a text file that I want to edit using Java. It has
If I made a program that stores strings on a text file using the
I have a text file which has the following structure: 341|18 Hello world|20090225230048AAnhStI|90|$0.30|10|289|2|2|2|Is that
I'm writing to a text file using the following declaration: void create_out_file(char file_name[],long double
How can I read a Chinese text file using C#, my current code can't
I'm using VS 2008 and need to read text files that have UTF-8 Chinese
I have to store relational data (text, numbers and pictures) into an XML file.
I'm using a preformatted text file as a template for emails. The file has
When reading lines from a text file using python, the end-line character often needs

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.