title: Spring Boot - Reading Text File using ResourceLoader
body: <p>I’m trying to read a text file using Spring resource loader like this :</p>
  
  <pre><code>Resource resource  = resourceLoader.getResource("classpath:\\static\\Sample.txt");
  </code></pre>
  
  <p>The file locates  here in my Spring boot project:
  <a href="https://i.stack.imgur.com/eSScg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eSScg.png" alt="enter image description here"></a></p>
  
  <p>It works fine when running the application in eclipse, but when I package the application then run it using java –jar , I get file not found exception :</p>
  
  <pre><code>java.io.FileNotFoundException: class path resource [static/Sample.txt] cannot be resolved to absolute file path because it does not reside in the
   file system: jar:file:/C:/workspace-test/XXX/target/XXX-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/static/Sample.txt
  </code></pre>
  
  <p>I unziped the Jar file the Sample locates in :
  XXX-0.0.1-SNAPSHOT\BOOT-INF\classes\static\Sample.txt </p>
  
  <p>Can someone help me please ?</p>
  
  <p>Thanks in advance!</p>