Zoom
1234567 7
public class fileProcessor (
private BufferedReader reader;private String FilePath;
public void openFile (String filePath) {
try {
reader new BufferedReader (new FileReader (filePath));
if (filePath != null || filePath.isEmpty()) { System.out.println("File opened successfully");
}
} catch (IOException e) {
System.out.println("Error opening file: " + e.getMessage());
public void readFile() {
String line;
try {
while ((line = reader.readLine()) != null) {
System.out.println(line);
} catch (IOException e) {
8
9
10
11
12
13
}
14
15
16
17
18
19
20
21
22
23
24
25
}
26
27
28
29
30
31
32
}
33
34
}
35
System.out.println("Error reading file: " + e.getMessage());
} finally {
reader.close();
public void processFile() { openFile (FilePath);
System.out.println("Processing file...");if (FilePath == null) {
System.out.println("Invalid file path");
return;
readFile();
Question 2 (5 points):
+ 100%
Close