Create a file called Display.java Write a try-catch statement that attemps to create a Scanner object to read from the logfile ('logfile.txt'). If the file does not exist, catch the FileNotFoundException, print "Cannot find logfile!" then "Exiting..." and quit the program. If the file exists, prompt the user to enter start and end indices Print out all the lines between the start and end line numbers (inclusive).
public class CopyOfDIsplay {
public static void main(String[] args) throws IOException {
File file = new File("C:\\Users\\vutom\\IdeaProjects\\COS101 TERM4 ASSIGNMENT\\src\\logfile.txt");
FileInputStream fileInputStream = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String line = bufferedReader.readLine();
String[] Numberz = line.split(":");
Scanner s = new Scanner(System.in);
System.out.println("Enter two numbers , a start and end index separated by a space:");
String Inputs = s.nextLine();
String[] numbers = Inputs.split("\s");
String rangeMin = numbers[0];
String rangeMax = numbers[1];
int start = Integer.parseInt(rangeMin);
int end = Integer.parseInt(rangeMax);
try {
while (line != null) {
for (String num :Numberz) {
if (line.codePointAt(start) >= && line.codePointAt(end) <= end) {
System.out.println(line);
}
else {
System.out.println(line);
}
}
}
bufferedReader.close();
} catch (FileNotFoundException e) {
System.out.println("Cannot find logfile");
} catch (IOException ex) {
throw new RuntimeException(ex);
}
System.out.println("Exiting. . . ");
}
}