title: producing an empty zip file java
body: <p>I'm currently writing a function what would create a zip file, which will be used in other functionality. Below it is my function's code:</p>
  
  <pre><code>public void createZip(){
  
          try{
              String outfile = this.filename + ".zip";
              //input file
              FileInputStream input = new FileInputStream(this.filename);
              //output file
              ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(outfile));
              //name the file inside the zip file
              System.out.println(this.filename);
              zip.putNextEntry(new ZipEntry(this.filename));
  
              byte[] buffer = new byte[this.BUFFER];
              int len;
              //copy the file to the zip
              while((len= input.read(buffer)) &gt; 0){
                  System.out.println(len);
                  zip.write(buffer, 0, len);
              }
              zip.closeEntry();
              zip.flush();
              input.close();
              zip.close();
              this.filename += ".zip";
          }
          catch(IOException e){
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>I have tried to debug, but I couldn't find the source of this problem. The function runs without any further problems, but the zip file produced it is an empty one.</p>