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

  • Home
  • SEARCH
  • 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 4008022
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:42:11+00:00 2026-05-20T08:42:11+00:00

A program I am working on right now has to generate a file. Is

  • 0

A program I am working on right now has to generate a file. Is it better for me to generate the file’s contents as a string first and then write that string to the file, or should I just directly add the contents to the file?

Are there any advantages of one over the other?

The file will be about 0.5 – 1MB in size.

  • 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-20T08:42:11+00:00Added an answer on May 20, 2026 at 8:42 am

    If you write to a file as-you-go, you’ll have the benefit of not keeping everything in memory, if it’s a big enough file and you constantly flush the stream.

    However, you’ll be more likely to run into problems with a partially-written file, since you’re doing your IO over a period of time instead of in a single shot.

    Personally, I’d build it up using a StringBuilder, and then write it all to disk in a single shot.

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

Sidebar

Related Questions

Okay so right now I'm working on a program that has a whole bunch
A program i am working on deals with processing file content. Right now i
My professor has asked us to write a program that uses recursion to solve
I'm working on a C++ program that will automatically backup my work to my
A project I have been working on for the past year writes out log
This relates to a project to convert a 2-way ANOVA program in SAS to
I have 4 UITextFields that I'm dynamically creating, in the viewDidLoad, which works good.
got a new lenny installation now, we are a small team of 3 devs
We are a small group of six developers who currently use Visual Studio 2003
I have a feeling my problem is a bit strange, but here goes... I

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.