title: store file in spring boot resource folder after deployment
body: <p>I have deployed a spring-boot application JAR file. Now, I want to upload the image from android and store it in the myfolder of resource directory. But unable to get the path of resource directory.</p>
  <p>Error is:
  <strong>java.io.FileNotFoundException: src/main/resources/static/myfolder/myimage.png
  (No such file or directory)</strong></p>
  <p>This is the code for storing the file in the resource folder</p>
  <pre><code>private final String RESOURCE_PATH = &quot;src/main/resources&quot;;
  String filepath = &quot;/myfolder/&quot;;
  
  public String saveFile(byte[] bytes, String filepath, String filename) throws MalformedURLException, IOException {
  
  File file = new File(RESOURCE_PATH + filepath + filename);
      
  OutputStream out = new FileOutputStream(file);
  try {
      out.write(bytes);
  } catch (Exception e) {
      e.printStackTrace();
  } finally {
      out.close();
  }
  return file.getName();
  </code></pre>
  <p>}</p>
  <p><strong>UPDATED:</strong></p>
  <p>This is what I have tried</p>
  <pre><code>private final String RESOURCE_PATH = &quot;config/&quot;;
  controller class: 
  
  String filepath = &quot;myfolder/&quot;;
  String filename = &quot;newfile.png&quot;
  
  public String saveFile(byte[] bytes, String filepath, String filename) throws MalformedURLException, IOException {
      
      //reading old file      
      System.out.println(Files.readAllBytes(Paths.get(&quot;config&quot;,&quot;myfolder&quot;,&quot;oldfile.png&quot;)));  //gives noSuchFileException
      
      //writing new file
      File file = new File(RESOURCE_PATH + filepath + filename);
  
      OutputStream out = new FileOutputStream(file);  //FileNotFoundException
      try {
          out.write(bytes);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          out.close();
      }
      return file.getName();
  }
  </code></pre>
  <p>Project structure:</p>
  <pre><code>+springdemo-0.0.1-application.zip
     +config
       +myfolder
          -oldfile.png
       -application.properties
     +lib
       +springdemo-0.0.1.jar
     +start.sh
  -springdemo-0.0.1.jar       //running this jar file
  </code></pre>