Why there's an error in the following program which has been written in a similar way as been taught by the professor in the lecture.
Title
Question
https://drive.google.com/file/d/1pVz5H5AdnYJDrTSI0r-cMt35RCyUOHkk/view?usp=sharing
https://drive.google.com/file/d/1ZL-XFEBM29sJeBqgf28FI28GpcFun3F_/view?usp=sharing
Java Exception-Handling 07-08 min 20-30 sec
Answers:
You need to import classes as highlighted in the following code snippet.
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;
public class MarksFile
{
public static void main(String[] args)
{
FileReader fr=null;
try
{
fr=new FileReader("C://Users/Shubhankar/Demo/Gemini.txt");
}
catch (FileNotFoundException e)
{
//TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
System.out.println("Inside finally block");
try
{
fr.close();
}
catch (IOException e)
{
//TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Login to add comment