Here you can find the source of writeFile(ZipEntry entry, ZipFile zipFile, File file)
private static void writeFile(ZipEntry entry, ZipFile zipFile, File file) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 EclipseSource and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://w ww . j a v a 2 s . co m * Holger Staudacher - initial API and implementation, ongoing development ******************************************************************************/ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import com.google.common.io.ByteStreams; public class Main { private static void writeFile(ZipEntry entry, ZipFile zipFile, File file) throws IOException { if (!buildDirectory(file.getParentFile())) { throw new IOException("Could not create directory: " + file.getParentFile()); } if (!entry.isDirectory()) { copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(file))); } else { if (!buildDirectory(file)) { throw new IOException("Could not create directory: " + file); } } } private static boolean buildDirectory(File file) { return file.exists() || file.mkdirs(); } private static void copyInputStream(InputStream in, OutputStream out) throws IOException { try { ByteStreams.copy(in, out); } finally { in.close(); out.close(); } } }