I am not getting the desired output as shown in the lecture neither for error type nor for found file type
Title
Question
Madam/Sir,
Please go through the following Google Drive links to rectify my problem which I haven't found during regular lectures:-
https://drive.google.com/file/d/1FV4fnZ6uNGzaXNOdPdwMQTrgly87wMgh/view?usp=sharing
https://drive.google.com/file/d/1AS8xZhBR0j7t50TyfQ5XNP7Fa732_fkR/view?usp=sharing
Java Exception-Handling 08-09 min 30-40 sec
Answers:
Make sure to import packages as highlighted below.
import java.io.FileNotFoundException;
import java.io.FileReader;
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