title: Sonar: How to use try-with-resources to close FileOutputStream
body: <p>Sonar is giving an error that this <code>FileOutputStream</code> should be closed. I need to modify the following code to use <code>try-with-resources</code>. How do I do this?</p>
  
  <pre><code>public void archivingTheFile(String zipFile){
      byte[] buffer = new byte[1024];
      try{
          FileOutputStream fos = new FileOutputStream(zipFile);
          ZipOutputStream zos = new ZipOutputStream(fos);
          for(String file : this.fileList){
              ZipEntry ze= new ZipEntry(file);
              zos.putNextEntry(ze);
              FileInputStream in = new FileInputStream(SOURCE_FOLDER + File.separator + file);
              int len;
              while ((len = in.read(buffer)) &gt; 0) {
                  zos.write(buffer, 0, len);
              }
              in.close();
          }
          zos.closeEntry();
          zos.close();
      }catch(IOException ex){
          LOGGER.error("Exception occurred while zipping file",ex);
      }
  }
  </code></pre>