Here you can find the source of extractFile(ZipInputStream zipIn, Path filePath)
Parameter | Description |
---|---|
zipIn | a parameter |
filePath | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
private static void extractFile(ZipInputStream zipIn, Path filePath) throws IOException
//package com.java2s; //License from project: Creative Commons License import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.file.Path; import java.util.zip.ZipInputStream; public class Main { /**/*from w ww . j a v a 2s .c o m*/ * Size of the buffer to read/write data */ private static final int BUFFER_SIZE = 4096; /** * Extracts a zip entry (file entry) * * @param zipIn * @param filePath * @throws IOException */ private static void extractFile(ZipInputStream zipIn, Path filePath) throws IOException { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(filePath.toFile().getAbsolutePath())); byte[] bytesIn = new byte[BUFFER_SIZE]; int read = 0; while ((read = zipIn.read(bytesIn)) != -1) { bos.write(bytesIn, 0, read); } bos.close(); } }