title: How to read a static file on deployment on Spring Boot
body: <p>I want to be able to deploy my spring boot application onlne on heroku. My app loads data from a static .json file which is located on my resources folder.</p>
  
  <p><a href="https://i.stack.imgur.com/1J8J4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1J8J4.jpg" alt="enter image description here"></a></p>
  
  <p>So far I've tried this code but it doesn't work. For some reason I can't read the data from the json file.</p>
  
  <pre><code>    public List&lt;Category&gt; getAllCategories() throws FileNotFoundException
      {
         Gson gson = new Gson();
         ClassLoader classLoader = getClass().getClassLoader();
         File file = new File(classLoader.getResource("static/data/data.json").getFile());
         JsonReader reader = new JsonReader(new FileReader(file.getPath()));
         List&lt;Category&gt; allCategories = gson.fromJson(reader, new TypeToken&lt;List&lt;Category&gt;&gt;(){}.getType());
  
         return allCategories;
      }
  </code></pre>