Question: 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.


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
Get step-by-step solutions from verified subject matter experts
