extract File from Zip File - Java File Path IO

Java examples for File Path IO:Zip File

Description

extract File from Zip File

Demo Code


//package com.java2s;
import java.io.*;

import java.util.zip.ZipInputStream;

public class Main {
    private static void extractFile(ZipInputStream in,
            File outputDirectory, String name) throws IOException {
        final int BUFFER_SIZE = 1024;
        byte[] buffer = new byte[BUFFER_SIZE];
        BufferedOutputStream out = new BufferedOutputStream(
                new FileOutputStream(new File(outputDirectory, name)));
        int count;
        while ((count = in.read(buffer)) != -1) {
            out.write(buffer, 0, count);
        }/*from w ww.  ja  v  a  2  s.c  om*/
        out.close();
    }
}

Related Tutorials