I understand that try-with resources automatically closes the streams but what if you wantt to use try with catch block. I'm clueless as why this codes is wrong and the validator is even more confusing.
package com.codegym.task.task18.task1824;

/*
Files and exceptions

*/

import java.io.*;

public class Solution {
    public static void main(String[] args) throws IOException {
        //step 1: The program should read file names from the console.
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String fileName = reader.readLine();

        while(true) {
            FileInputStream fis = null;
            try {
                fis = new FileInputStream(fileName);//if fileName doesn't exist is will automatically throw a FileNotFoundException
            } catch (FileNotFoundException ex) {
                System.out.println(fileName);
                fis.close();
                reader.close();
                break;
            }

        }




        /*while(true){
            String fileName = reader.readLine();
            try (FileInputStream fis = new FileInputStream(fileName)){

            } catch (FileNotFoundException ex){
                System.out.println(fileName);
                break;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }*/


    }
}