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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:19:05+00:00 2026-06-10T07:19:05+00:00

I have 1 file, which contains some String that need to be updated. MY

  • 0

I have 1 file, which contains some String that need to be updated.

MY REPORT
REPORT RUN DATE : 27/08/2012 12:35:11 PAGE 1 of @TOTAL@                                              
SUCCESSFUL AND UNSUCCESSFUL DAILY TRANSACTIONS REPORT                                                                                    
---record of data here----

MY REPORT                                                                                                                                                 
REPORT RUN DATE : 27/08/2012 12:35:11 PAGE 2 of @TOTAL@                                              
SUCCESSFUL AND UNSUCCESSFUL DAILY TRANSACTIONS REPORT
---record of data here----

In case I just want to update all occurence of @TOTAL@ to some number, is there a quick and effecient way to do this?

I understand that I can also use BufferedReader+BufferedWriter to print to another file and use String.replace it along the way, but I wonder if there is a better and elegant way to solve this…

The file wont exceed 10MB, so there is no need to concern whether the file can be to big ( exceed 1 GB etc )

  • 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-10T07:19:06+00:00Added an answer on June 10, 2026 at 7:19 am

    … I wonder if there is a better and elegant way to solve this

    It depends on what you mean by “better and elegant”, but IMO the answer is no.

    The file wont exceed 10MB, so there is no need to concern whether the file can be to big ( exceed 1 GB etc )

    You are unlikely to exceed 1Gb. However:

    • You probably cannot be 100% sure that the file won’t be bigger that 10Mb. For any program that has a significant life-time, you can rarely know that the requirements and usage patterns won’t change over time.

    • In fact, a 10Mb text file may occupy up to 60Mb of memory if you load the entire lot into a StringBuilder. Firstly, the bytes are inflated into characters. Secondly, the algorithm used by StringBuilder to manage its backing array involves allocating a new array of double the size the original one. So peak memory usage could be up to 6 times the number of bytes in the file you are reading.

    • Note that 60Mb is greater than the default maximum heap size for some JVMs on some platforms.

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

Sidebar

Related Questions

I have a .resx file which contains some string resources for my project. At
i have a file which contains a lot of update query and some other
I have a text file which contains data seperated by '|'. I need to
I have a text file which contains data I need to preload into a
I have a CSS file, which contain the style information of my web. Some
I have a file which contains lines of data in the following format: a11
I am using Ruby (1.9.3) and Rails (3.2.2). I have tasks file which contains
I have a JSON file which contains a pound symbol in it. This json
I have a JSON file which contains HTML content. I want to load it
I have a dotx file which contains placeholders to be replaced with DB values

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.