Question: In Java create a file named A9.java. Place all your code in this file. Write a static method in the public class A9 named readSecondLine
In Java create a file named A9.java. Place all your code in this file.
Write a static method in the public class A9 named readSecondLine that takes as input a String path and returns a String. Your method should read from the file at the specified path and start reading line by line. It should return the second line. Note: You must still close your file! There are two ways to ensure you close your file after returning. 1) Try with resources 2) Close the file in the finally finally is called even if you return inside the try. Note: When a method fails to return the correct object, you can return null at the end.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
