exense-basic-commons/src/main/java/ch/exense/commons/io/FileHelper.java
/**
	 * Extracts the zip provided as stream to the target folder provided as argument
	 * @param stream the {@link InputStream} of the zip to be extracted
	 * @param target the target folder to extract to
	 * @throws IOException
	 */
Extracts the zip provided as stream to the target folder provided as argument
@param stream the  InputStream of the zip to be extracted
@param target the target folder to extract to
@throws IOException
Extracts the zip provided as stream to the target folder provided as argument @param stream the InputStream of the zip to be extracted @param target the target folder to extract to @throws IOException
public static void unzip(InputStream stream, File target) throws IOException {
		try (ZipInputStream zip = new ZipInputStream(stream)){
			target.mkdir();
			ZipEntry entry;
			while ((entry = zip.getNextEntry()) != null) {
				String currentEntry = entry.getName().replaceAll("\\\\","/");
				File destFile = new File(target.getAbsolutePath(), currentEntry);
				File destinationParent = destFile.getParentFile();
				destinationParent.mkdirs();
				if (!entry.isDirectory()) {
					byte data[] = new byte[DEFAULT_BUFFER_SIZE];
					FileOutputStream fos = new FileOutputStream(destFile);
					BufferedOutputStream dest = new BufferedOutputStream(fos, DEFAULT_BUFFER_SIZE);
					int currentByte;
					while ((currentByte = zip.read(data, 0, DEFAULT_BUFFER_SIZE)) != -1) {
						dest.write(data, 0, currentByte);
					}
					dest.flush();
					dest.close();
				}
			}
		}
	}
public static void unzip ( InputStream stream , File target ) throws IOException { try ( ZipInputStream zip = new ZipInputStream ( stream ) ) { target . mkdir ( ) ; ZipEntry entry ; while ( ( entry = zip . getNextEntry ( ) ) != null ) { String currentEntry = entry . getName ( ) . replaceAll ( "\\\\" , "/" ) ; File destFile = new File ( target . getAbsolutePath ( ) , currentEntry ) ; File destinationParent = destFile . getParentFile ( ) ; destinationParent . mkdirs ( ) ; if ( ! entry . isDirectory ( ) ) { byte data [ ] = new byte [ DEFAULT_BUFFER_SIZE ] ; FileOutputStream fos = new FileOutputStream ( destFile ) ; BufferedOutputStream dest = new BufferedOutputStream ( fos , DEFAULT_BUFFER_SIZE ) ; int currentByte ; while ( ( currentByte = zip . read ( data , 0 , DEFAULT_BUFFER_SIZE ) ) != - 1 ) { dest . write ( data , 0 , currentByte ) ; } dest . flush ( ) ; dest . close ( ) ; } } } }
Extracts the zip provided as stream to the target folder provided as argument
 @param stream the {@link InputStream} of the zip to be extracted
 @param target the target folder to extract to
 @throws IOException
Extracts the zip provided as stream to the target folder provided as argument @param stream the { @link InputStream } of the zip to be extracted @param target the target folder to extract to @throws IOException