Search and Replace Content inside a File

Search and Replace Content inside a File
Today, We are going to see how to search a file for specific content and replace the content and write to a new File.

Let us create a text document with some content in it

screen1

Now we are going to write a code to change “File 1” into “File 2”, The content will be

“Sample Content in File 2”

Once the code is executed, File2.txt will get created and content will be,

screen2

 

Leave a Reply

Your email address will not be published. Required fields are marked *