title: Can't find resource outside the jar
body: <p>I am trying to read properties which is located external to the jar file of my code.using <code>ResourceBundle</code> but its unable to read the property file <code>locations.properties</code>. The property file is located under <code>resource</code> folder and both <code>jar</code> and <code>resource</code> folder are under same directory.</p>
  
  <pre><code>myDir
  
     --&gt; myJar.jar
     --&gt; resource
            --&gt;locations.properties
  </code></pre>
  
  <p>I don't know whats wrong with my code below:</p>
  
  <pre><code>public static ResourceBundle getResourceBundle(String fileName) throws MalformedURLException{
      if (resourceBundle == null) {
          File file = new File("resource/"+fileName);
          URL[] urls = { file.toURI().toURL() };
          ClassLoader loader = new URLClassLoader(urls);
          resourceBundle = ResourceBundle.getBundle(fileName, Locale.getDefault(), loader);
      }
      return resourceBundle;
  }
  </code></pre>
  
  <p>And this is how am invoking <code>ResourceBundle</code> object:</p>
  
  <pre><code>ResourceBundle locationBundle = null;
  try {
      locationBundle = ReadPropertyUtil.getResourceBundle(propFileName);
  } catch (MalformedURLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Please guide whats wrong with this code and whats the correct way of reading an external properties file.</p>