Add string in a file

  • Thread starter Thread starter S. Senthil Kumar
  • Start date Start date
S

S. Senthil Kumar

Really simple, open the file in append mode and write out the string to
the file.
 
I want to add a string to a file after a specific string for example
"abcde",
Which means I need to open the file find the string "abcde" and then add my
string just after.
How do I do it?

Yoav.
 
Here's the simplest way:
1) Read the entire file to memory.
2) Search for the string.
3) Insert a new string after the found string.
4) Write to the file.
 
I need to add the string just after another string ("abcde") that I need to
find.
For example if my file context is:

"This is a my abcde file"

and my added string is "xxx", so I want the result of the file to be:

"This is a my abcde xxx file"
 
Back
Top