Работа с ресурсами Intellij Idea

Работа с ресурсом, как с потоком

import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) {
        try {
            URL resource=Main.class.getResource("data.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream()));

            String line = null;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);

            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch(URISyntaxException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    // write your code here
}