Java Utililty Methods ZipOutputStream Write

List of utility methods to do ZipOutputStream Write

Description

The list of methods to do ZipOutputStream Write are organized into topic(s).

Method

voidzipFile(ZipOutputStream zos, BufferedOutputStream out, File destPath, String originalPath)
zip File
BufferedReader in = new BufferedReader(new FileReader(destPath));
zos.putNextEntry(new ZipEntry(destPath.getAbsolutePath().substring(originalPath.length())));
int c;
while ((c = in.read()) != -1)
    out.write(c);
in.close();
StringzipFile(ZipOutputStream zos, File file, String requestName, byte[] buf)
zip File
String fileName = requestName == null ? file.getName() : requestName;
zos.putNextEntry(new ZipEntry(fileName));
FileInputStream fis = new FileInputStream(file);
int read;
while ((read = fis.read(buf)) > 0) {
    zos.write(buf, 0, read);
fis.close();
...
voidzipFile(ZipOutputStream zout, File file, int rootLength)
zip File
FileInputStream fin;
ZipEntry ze;
byte[] buffer = new byte[10000];
int bytesread;
String entryname = file.getAbsolutePath().substring(rootLength);
entryname = entryname.replaceAll("\\\\", "/");
ze = new ZipEntry(entryname);
if (file.exists()) {
...
voidzipInternal(String path, File file, ZipOutputStream os)
zip Internal
String filePath = path + "/" + file.getName();
if (file.isDirectory()) {
    for (File f : file.listFiles())
        zipInternal(filePath, f, os);
} else {
    ZipEntry entry = new ZipEntry(filePath);
    os.putNextEntry(entry);
    FileInputStream in = new FileInputStream(file);
...
voidzipInternal(String path, File file, ZipOutputStream os, boolean justFolders, boolean skipManifest)
zip Internal
String filePath;
if (path.isEmpty())
    filePath = file.getName();
else
    filePath = path + "/" + file.getName();
if (file.isDirectory()) {
    if (justFolders) {
        if (!filePath.equalsIgnoreCase("META-INF") || !skipManifest) {
...
voidzipIt(ZipOutputStream zos, String[] directoriesAndFiles, CRC32 crc)
Zip directory content in the given output stream
for (String pathElement : directoriesAndFiles) {
    File fileElement = new File(pathElement);
    pathElement = fileElement.getPath();
    int length = pathElement.lastIndexOf(File.separator) + 1;
    if (fileElement.isFile()) {
        zipFile(pathElement, length, zos, crc);
    } else if (fileElement.isDirectory()) {
        zipDirectory(pathElement, length, zos, crc);
...
voidzipOneFile(File file, String base, ZipOutputStream zout)
zip One File
String name = base + file.getName();
ZipEntry entry = new ZipEntry(name);
entry.setTime(file.lastModified());
zout.putNextEntry(entry);
FileInputStream in = new FileInputStream(file);
try {
    long size = file.length();
    int chunkSize = 100 * 1024;
...
voidzipOneFile(File file, ZipOutputStream out, String relativePath)
Introduce un fichero en el stream de zip.
PrintWriter outTraceFile = new PrintWriter(
        new BufferedWriter(new FileWriter(XLIM_LOGS_WORK_DIR + FILE_SEPARATOR + "zip.log", true)), true);
if (file.isDirectory()) {
    outTraceFile.println("Zipping..." + file.getPath());
    String[] fileNamesInDir = file.list();
    if (fileNamesInDir != null) {
        for (int i = 0; i < fileNamesInDir.length; i++) {
            zipOneFile(new File(file, fileNamesInDir[i]), out, relativePath);
...
voidzipOneFile(String prefix, File file, ZipOutputStream zos)
Zips a single file.
ZipEntry zipFileEntry = new ZipEntry(prefix + file.getName());
InputStream in = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
int c;
zos.putNextEntry(zipFileEntry);
while ((c = in.read()) != -1) {
    zos.write(c);
in.close();
...
voidzipRecurse(File file, int prefixLength, ZipOutputStream zos)
zip Recurse
ZipEntry entry = null;
try {
    String name = file.getAbsolutePath() + (file.isDirectory() ? "/" : "");
    name = name.substring(prefixLength);
    if (name.length() > 0) {
        entry = new ZipEntry(name);
        zos.putNextEntry(entry);
        if (file.isFile()) {
...