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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:53:51+00:00 2026-06-11T13:53:51+00:00

I am reading each line in the text file, do some with the file

  • 0

I am reading each line in the text file, do some with the file and write back to same file using Java. And, position(index) of each value in the line is important. So I need to preserve the location of the each value.

How do I remove a “space” character at specific location(index)?

Say, below is the line that I read,

.... ABC   123....  --There are 3 spaces between ABC and 123

Basically, I want to make the above line written as 2 spaces between ABC and 123.

At first, I was just using replaceAll of String but that just shift the the values to right by one and still 3 spaces. So, I figure I need more than just replaceAll.

Now, I am getting a position of where ABC is found and just trying to remove that 1 space.

  • 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-11T13:53:52+00:00Added an answer on June 11, 2026 at 1:53 pm

    If you want to remove a single character, just use StringBuilder.deleteCharAt.

    final int pos = ...;
    str = new StringBuilder(str).deleteCharAt(pos).toString();
    

    I explicitly advise you not to do the substring approach.

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

Sidebar

Related Questions

Here I'm reading text file which contains a integer in each line and I'm
I am trying to replace text in a text file by reading each line,
I'm running a while loop reading each line in a file, and then fork
I have a huge line-separated text file and I want to make some calculations
I am reading from a text file line by line. StreamReader reader = new
I have a loop that's reading over a text file. Each time the loop
Given a text file, how would I go about reading an arbitrary line and
I am using Powershell for some ETL work, reading compressed text files in and
I am trying to read some text files, where each line needs to be
I have a text file with 50k+- lines and each line contains data which

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.