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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:29:34+00:00 2026-05-11T00:29:34+00:00

Is there a way I can write text to a file from a certain

  • 0

Is there a way I can write text to a file from a certain point in the file?

For example, I open a file of 10 lines of text but I want to write a line of text to the 5th line.

I guess one way is to get the lines of text in the file back as an array using the readalllines method, and then add a line at a certain index in the array.

But there is a distinction in that some collections can only add members to the end and some at any destination. To double check, an array would always allow me to add a value at any index, right? (I’m sure one of my books said other wise).

Also, is there a better way of going about this?

Thanks

  • 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. 2026-05-11T00:29:34+00:00Added an answer on May 11, 2026 at 12:29 am

    Oh, sigh. Look up the ‘master file update’ algorithm.

    here’s pseudocode:

    open master file for reading. count := 0 while not EOF do     read line from master file into buffer     write line to output file         count := count + 1     if count = 5 then        write added line to output file     fi od rename output file to replace input file 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 64k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer @Theo.T, thanks for the tip. It didn't solve my problem… May 11, 2026 at 10:56 am
  • added an answer I echo the suggestion of drawing them on paper first… May 11, 2026 at 10:56 am
  • added an answer AtomicBoolean was also added in JDK5, so this isn't available… May 11, 2026 at 10:56 am

Related Questions

Is there a way I can write text to a file from a certain
Is there a way to write an enumeration that can be extended. I have
Is there a way I can control columns from code. I had a drop
Is there a way I can access (for printout) a list of sub +
Is there a way I can create Windows firewall exceptions in VB2005? I'm trying
Is there a way I can set up callbacks on (or automataically log) method
Is there a way I can upload a file to my web server to
In the iPhone is there a way I can use JavaScript to close the
Assuming Windows, is there a way I can detect from within a batch file
I am writing a console program in C#. Is there a way I can

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.