Sonar: How to use try-with-resources to close FileOutputStream
问题 Sonar is giving an error that this FileOutputStream should be closed. I need to modify the following code to use try-with-resources . How do I do this? 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