This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
i have a problem in file handling. i have to read a file for a text pattern, and whenever it is encountered, i have to insert a line of text before it, and a line of text after the pattern. how do i go about it?
You read one file and write a second file. When you read text that doesn't match the pattern, you copy it unchanged to the second file. When you do match the pattern, you write the data you describe in your message. Finally, you rename the original file, rename the new file to the original name, and delete the original file.