title: How to load resource from jar before outside file in Java?
body: <p>I have the following problem:
  I try to load a file from jar but I have the same file outside situated at the same relative path: "res/rtrconfig" as the file in jar. How can I ignore the outside file and get the jar file path?. I can't delete the outside file because other parts of my code need it.
     What I've got until now:</p>
  
  <pre><code>ClassLoader loader = Thread.currentThread().getContextClassLoader();
          URL url = loader.getResource(path);
          //check if file is in jar or not
          if (url == null) {
              System.err.println("FATAL: Properties file not found.Stopping the server.");
              System.exit(-1);
          }
          if ( !url.getProtocol().equals("jar")){
  
              System.err.println("Properties found outside jars.Please delete " + url.getPath() + " and re-start the server");
              System.exit(-1);
          }
  </code></pre>
  
  <p>This part of code checks if the file is founded in jar or in path.
  I don't know how to configure URL to look after file in jar before file in path.
  Thanks for your time.</p>