title: java 9 resource file different module NoSuchFileException
body: <p>I am trying to load a file which is present in the resources folder, but getting an exception.
  I am using java 9, and the java file that has the code to read the file is present in some other module and the calling code is in some other module.
  Can some one please suggest how to proceed here?</p>
  
  <p><a href="https://i.stack.imgur.com/ntQna.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntQna.png" alt="enter image description here"></a></p>
  
  <p>Exception stacktrace</p>
  
  <pre><code>java.nio.file.NoSuchFileException: genome-tags.csv
      at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85)
      at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
      at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
      at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:231)
      at java.base/java.nio.file.Files.newByteChannel(Files.java:364)
      at java.base/java.nio.file.Files.newByteChannel(Files.java:410)
      at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
      at java.base/java.nio.file.Files.newInputStream(Files.java:154)
      at java.base/java.nio.file.Files.newBufferedReader(Files.java:2809)
      at java.base/java.nio.file.Files.readAllLines(Files.java:3239)
      at java.base/java.nio.file.Files.readAllLines(Files.java:3279)
      at com.bhargo.filesystem.reader/com.bhargo.filesystem.reader.FileSystemReader.read(FileSystemReader.java:15)
      at com.bhargo/com.bhargo.Main.main(Main.java:20)
  </code></pre>
  
  <p>The code is:-</p>
  
  <pre><code>    public class Main {
  
          public static void main(String[] args) {
              ServiceLoader&lt;IReader&gt; serviceLoader = ServiceLoader.load(IReader.class);
              try {
                  System.out.println(serviceLoader.iterator().next().read("genome-tags.csv", Main.class).size());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
      }
  
  
      public interface IReader {
      List&lt;String&gt; read(String fileLocation, Class clazz) throws IOException;
  
      default File getFile(String fileLocation, Class clazz) {
          URL url = clazz.getResource(fileLocation);
          return new File(getClass().getClassLoader().getResource(fileLocation).getFile());
      }
  }
  
  
      public class FileSystemReader implements IReader{
          @Override
          public List&lt;String&gt; read(String fileLocation, Class clazz) throws IOException {
              return Files.readAllLines(Paths.get(getFile(fileLocation, clazz).getName()));
          }
      }
  </code></pre>
  
  <p>Thanks,</p>
  
  <p>Amar</p>