/** * * @param file * @param dest * Where the zipped file will be stored * @return zipped file */ public static File zip(File file, String dest) { File zippedFile = new File(dest + "/" + file.getName() + ".zip"); try { FileOutputStream ops = new FileOutputStream(zippedFile); ZipOutputStream zos = new ZipOutputStream(ops); zip(file, zos, ""); zos.close(); } catch (FileNotFoundException fnfex) { fnfex.printStackTrace(); } catch (IOException ioex) { ioex.printStackTrace(); } return zippedFile; }
zip(entries[i], zos, prefix + entries[i].getName() + "/"); ZipEntry zi = new ZipEntry(prefix + entries[i].getName()); zos.putNextEntry(zi); copystream(fis, zos); zos.closeEntry();
BufferedOutputStream bos = new BufferedOutputStream(fos); InputStream in = zipFile.getInputStream(ze); totalsize += copystream(in, bos); bos.close();