Please help.
package com.codegym.task.task13.task1318;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.io.FileInputStream;
/*
Reading a file
1. The program must read the file name from the console.
2. The program must display the contents of the file.
3. You must close the file input stream (FileInputStream).
4. The BufferedReader must also be closed.
*/
public class Solution {
public static void main(String[] args) {
try {
// Initialize BufferdReader to get filename from user
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Get filename from user
String fileName = reader.readLine();
//Initialize FileInputStream with user-provided filename
FileInputStream inStream = new FileInputStream(fileName);
// Loop to read file and print it to console
while (inStream.available() > 0){ //Continue Loop as long as FileInputStream is not at the end of the file
int data = inStream.read(); //Int variable data is equal to current byte in file
System.out.print(data); //Print current byte to console
}
reader.close(); //Close BufferedReader
inStream.close(); //Close FileInputStream
}
catch (Exception e){
}
}
}