Java ZipOutputStream Write zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)

Here you can find the source of zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)

Description

zip File

License

Open Source License

Declaration

private static void zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)
            throws IOException 

Method Source Code


//package com.java2s;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;

import java.io.FileReader;
import java.io.IOException;

import java.util.zip.ZipEntry;

import java.util.zip.ZipOutputStream;

public class Main {
    private static void zipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)
            throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(destPath));
        zos.putNextEntry(new ZipEntry(destPath.getAbsolutePath().substring(originalPath.length())));
        int c;/*w ww . j a va  2  s  .c  o m*/
        while ((c = in.read()) != -1)
            out.write(c);
        in.close();
    }
}

Related

  1. zipAutoBase(File f, File base, ZipOutputStream out)
  2. zipFile(ZipOutputStream out, File file, String dir)
  3. zipFile(ZipOutputStream out, File sourceFile)
  4. zipFile(ZipOutputStream out, String stripPath, File file, char pathSeparator)
  5. zipFile(ZipOutputStream zipOut, String path, File file)
  6. zipFile(ZipOutputStream zos, File file, String requestName, byte[] buf)
  7. zipFile(ZipOutputStream zout, File file, int rootLength)
  8. zipInternal(String path, File file, ZipOutputStream os)
  9. zipInternal(String path, File file, ZipOutputStream os, boolean justFolders, boolean skipManifest)