title: Create file inside folder "resources" of spring project
body: <p>In my current spring, some forms have a field where the user can upload a file, which should be saves inside the folder <code>resources</code> from project (src/main/resources, following the structure created by maven).</p>
  
  <p>the method responsible for save the file in this folder is working ok until this line:</p>
  
  <pre><code>URL path = this.getClass().getClassLoader().getResource(file);
  </code></pre>
  
  <p>the variable <code>path</code> is staying with the value <code>null</code>. the variable <code>file</code> is defined with this value:</p>
  
  <pre><code>String file = "/"+this.getName()+"/"+String.valueOf(id)+"/picture.jpg";
  </code></pre>
  
  <p>Anyone can tell me the right way to do this?</p>
  
  <p>PS.: the complete code for this method is:</p>
  
  <pre><code>public boolean upload_picture(E e, MultipartFile f) {
      Integer id = null;
  
      if(f == null) {
          return false;
      }
  
      Class&lt;?&gt; clazz = e.getClass();
      Method methods[] = clazz.getDeclaredMethods();
      for(int i=0; i&lt;methods.length; i++) {
          if(methods[i].getName().equals("getId")) {
              try {
                  id = (Integer) methods[i].invoke(e);
              } catch (IllegalAccessException e1) {
                  e1.printStackTrace();
                  return false;
              } catch (IllegalArgumentException e1) {
                  e1.printStackTrace();
                  return false;
              } catch (InvocationTargetException e1) {
                  e1.printStackTrace();
                  return false;
              }
          }
      }
  
      BufferedImage src;
      try {
          src = ImageIO.read(new ByteArrayInputStream(f.getBytes()));
      } catch (IOException e3) {
          e3.printStackTrace();
          return false;
      }
  
      String file = "/"+this.getName()+"/"+String.valueOf(id)+"/picture.jpg";
      URL path = this.getClass().getClassLoader().getResource(file);
      File destination;
      try {
          destination = new File(path.toURI());
      } catch (URISyntaxException e2) {
          destination = new File(path.getPath());
          e2.printStackTrace();
      }
  
      try {
          ImageIO.write(src, "jpeg", destination);
          return true;
      } catch (IOException e1) {
          e1.printStackTrace();
          return false;
      }
  }
  </code></pre>