private static void zipFile ( final File srcFile , final String destPath , final ZipOutputStream out ) throws IOException { final byte [ ] buf = new byte [ 1024 ] ; try ( final InputStream in = new BufferedInputStream ( new FileInputStream ( srcFile ) ) ) { final ZipEntry zipEntry = new ZipEntry ( concatPathAndFilename ( destPath , srcFile . getName ( ) , File . separator ) ) ; zipEntry . setTime ( srcFile . lastModified ( ) ) ; out . putNextEntry ( zipEntry ) ; int len ; while ( ( len = in . read ( buf ) ) > 0 ) { out . write ( buf , 0 , len ) ; } out . closeEntry ( ) ; } }
Adds a file to a ZIP output stream .