title: Make zip from directory and download it In Spring without creating new files or directories
body: <p>I have a sample directory called <code>'sample-directory'</code>(in resources) with files and directories in it.</p>
  <p>this is my endpoint:</p>
  <pre><code>public void downloadZipFile(@RequestBody final Parameters parameter, final HttpServletResponse response) throws FileReadingException, IOException, URISyntaxException {
      response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
      response.setHeader(CONTENT_DISPOSITION, HEADER_VALUE_STR);
      response.setStatus(HttpServletResponse.SC_OK);
      this.generateZipService.generateZipFile(parameter, response);
  }
  </code></pre>
  <p>In my this.generateZipService.generateZipFile(parameter, resposne) method, I want to read all files from <code>'sample-directory'</code>, change some files here and download a zip file from this directory(includng all directories and files in it, including changes).</p>
  <p>Can someone suggest me or give direction how can I do this?</p>
  <p>I want to do it without creating new files or directories.</p>
  <p>like this:</p>
  <pre><code>for all files {
     if(currentFile is &quot;TEST1.xml&quot;) {
              change first Line here;
     }
     if(currentFile is &quot;TEST2.xml&quot;) {
              change second Line here;
     }
  }
  Then zip full directory and download.
  </code></pre>
  <p>Also I don't want to use <code>/src/main/resources</code> or paths like that.
  instead I'm using <code>getClass().getClassLoader().getResource(&quot;folderDirectlyInsideResources/otherPackages/file.txt&quot;);</code></p>
  <p>I have started implementing this by:</p>
  <pre><code>FileOutputStream fout = new FileOutputStream(&quot;src/main/resources/generate.zip&quot;);
  ZipOutputStream zout = new ZipOutputStream(fout);
  
  File folder = new File(&quot;src/main/resources/docker-compose-zip&quot;);
  File[] listOfFiles = folder.listFiles();
  
  for (File file : listOfFiles) {
      ZipEntry ze = new ZipEntry(file.getName());
      zout.putNextEntry(ze);
      zout.closeEntry();
  }
  zout.close();
  </code></pre>
  <p>but it downloads generate.zip file which is not zip(it is .txt format maybe). But I'm using <code>MediaType.APPLICATION_OCTET_STREAM_VALUE</code></p>