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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:08:10+00:00 2026-06-08T21:08:10+00:00

Do you know a java method to expand the chars of a text into

  • 0

Do you know a java method to expand the chars of a text into spaces?

My text:

1. <tab>  firstpoint  <tab> page  1
10. <tab> secondpoint <tab> page 10

If I directly replace the tab by, let say, 4 spaces, I will have

1.    firstpoint    page1
10.    secondpoint    page2

Instead of it, I need a method to replace each tab by the number of spaces it really corresponds to (as the command :retab of vim does). Any solution?

  • 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-08T21:08:12+00:00Added an answer on June 8, 2026 at 9:08 pm

    Although there’s probably a library out there that does this, the manual solution is quite simple:

    1. Create an output buffer (StringBuilder).
    2. Iterate through the string’s characters
    3. For each character check if it’s a tab or not.
      a. If it’s not a tab, add it to the output buffer.
      b. If it’s a tab, add a space first, then as many spaces as it takes for the length of the output buffer to be divisible by 4. (Your tab length.)
    4. Return the output buffer.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does anyone know if the following java Method in the java.util.concurrent Package ScheduledExecutorService.html#scheduleAtFixedRate() absolutely
We all know of sleep method available in java threads.. I understand that the
As we know, in Java, method name is not sufficient to distinguish different methods.
As you maybe know, as Java language perspective all method in C# are final
I'm curious to know if either of these two Java method invocations will behave
I have a static Java method, where I want to know who is its
I want to know how to call a java method from HTML (I Use
As you know, in a java interface, all methods have to be defined as
I know java well, and have some experience in EclipseLink, Hibernate, JSF, Grails and
I know Java's generics are somewhat inferior to .Net's. I have a generic class

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.