exense-basic-commons/src/main/java/ch/exense/commons/io/FileHelper.java
/**
	 * Extracts zip entry to file
	 * @param stream the {@link InputStream} of the zip to be extracted
	 * @return the extracted file
	 * @throws IOException
	 */
Extracts zip entry to file
@param stream the  InputStream of the zip to be extracted
@return the extracted file
@throws IOException
Extracts zip entry to file @param stream the InputStream of the zip to be extracted @return the extracted file @throws IOException
public static File unzip(InputStream stream, String entryName) throws IOException {
		File f = null;
		try (ZipInputStream zip = new ZipInputStream(stream)){
			ZipEntry entry;
			while ((entry = zip.getNextEntry()) != null) {
				if (!entry.isDirectory() && entry.getName().equals(entryName)) {
					f = FileHelper.createTempFile();				
					byte data[] = new byte[DEFAULT_BUFFER_SIZE];
					FileOutputStream fos = new FileOutputStream(f);
					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();
				}
			}
		}
		return f;
	}
public static File unzip ( InputStream stream , String entryName ) throws IOException { File f = null ; try ( ZipInputStream zip = new ZipInputStream ( stream ) ) { ZipEntry entry ; while ( ( entry = zip . getNextEntry ( ) ) != null ) { if ( ! entry . isDirectory ( ) && entry . getName ( ) . equals ( entryName ) ) { f = FileHelper . createTempFile ( ) ; byte data [ ] = new byte [ DEFAULT_BUFFER_SIZE ] ; FileOutputStream fos = new FileOutputStream ( f ) ; 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 ( ) ; } } } return f ; }
Extracts zip entry to file
 @param stream the {@link InputStream} of the zip to be extracted
 @return the extracted file
 @throws IOException
Extracts zip entry to file @param stream the { @link InputStream } of the zip to be extracted @return the extracted file @throws IOException