Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my question. Develop body of the following method public static void readWrite(String srcFileName, String dstFileName, String oldStr, String newStr) { } The method

This is my question.

image text in transcribedimage text in transcribed
Develop body of the following method public static void readWrite(String srcFileName, String dstFileName, String oldStr, String newStr) { } The method copies the content of thesrcFileNametodstFileNameline by line, and changes all occurance of theoldStringtonewStris thedstFileName. For example if the method is called by following parameters readWrite ("in.txt", "out.txt", " is ", " was "); // Note the the space before and after the words. if the content of thein.txtfile is this is a quiz, and this is an easy quiz. then the content of theout. txtwill be this was a quiz, and this was an easy quiz.OUTAWN import java. io. FileNotFoundException; import java. io. File; import java. io. PrintWriter; import java. util. Scanner; /** tests readWrite method * / public class Lab11Test{ public static void main (String args) throws FileNotFoundException{ 8 9 10 // test cases 11 readWrite("input. txt", "output1. txt", "Java", "JAVA") ; 12 readWrite("input. txt", "output2. txt", " is ", " was ") ; 13 14 15 16 ** Copies content of source file to destination file and changes all occurances of oldStr to new Str 17 @param srcFileName: source file name 18 @param dstFileName: destination file name 19 @param oldStri : old string that will be replace by new String 20 @param newStr : new string that will be substituted for the oldstr in the destination file 21 * / 22 public static void readWrite(String srcFileName, String dstFileName, String oldStr, String newStr) throws FileNotFoundException{ 23 // your code goes here 24 25 26 27 28

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions