Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The grepScanner method should read one line at a time from the Scanner object an

ID: 3770071 • Letter: T

Question

The grepScanner method should read one line at a time from the Scanner object and return all the lines that contain the pattern as a substring. public static ArrayList grepScanner(Scanner scanner, String pattern) {....... The grepFile method should call the above grepScanner method using a Scanner created from the File object. However, two runtime errors should be handled. If the file is not found, then this method should return an empty ArrayList. If file and/or pattern is null, then this method should return null. This method should not handle any other runtime errors. public static ArrayList grepFile(File file, String pattern) { try {.............

Explanation / Answer

please find the solution below:

?2?.?3? = scanner.hasNext

?7?(?8?) = indexOf(pattern)

?141? = file

?20? = IOException