When I want to load a file or asset(say an image) from file system into my program, I could either read the file directly from file system using something like
Files.readAllLines(Paths.get(fileName), StandardCharsets.UTF_8);
vs loading the file as a resource
getClass().getClassLoader().getResourceAsStream(fileName);
In Javadoc, Class#getResource() method, Javadoc specifies Resources in named modules are subject to the rules for encapsulation specified in the {@code Module} {@link Module#getResourceAsStream getResourceAsStream} method and so this method returns {@code null} when the resource is a non-"{@code .class}" resource in a package that is not open to the caller's module.
but I somehow could not wrap my head around what would be the deciding factor for me to load a file as a resource or simply read it from file system.