Question: Modify the below Java code so that the method Problem searches through the lines of a given txt file for a specific word entered by

Modify the below Java code so that the method Problem searches through the lines of a given txt file for a specific word entered by the user. This word will be passed as a string variable 'phrase'. You can assume that each line in file will contain chars only (no spaces). Read each line until you find the word entered (return true) or reach the end of the file (return false). Please ensure all three currently present methods remain in your answer. You can modify the body of methods as needed.

public class Problem3 {

public static void main(String[] args) {

new Problem3();

}

public Problem3() throws FileNotFoundException {

boolean problemSolution = Problem(new File("Problem3.txt"), null);

System.out.println(problemSolution);

}

public boolean Problem(File file, String phrase) {

// YOURCODEHERE

return false;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!