All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dstadler.commons.zip.ZipFileCloseInputStream Maven / Gradle / Ivy

There is a newer version: 1.3.4
Show newest version
package org.dstadler.commons.zip;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipFile;

/**
 * Small wrapper InputStream which closes the underlying zipfile as soon
 * as the InputStream is closed.
 *
 * @author dominik.stadler
 */
public class ZipFileCloseInputStream extends FilterInputStream {
	private final ZipFile zipFile;

	public ZipFileCloseInputStream(InputStream stream, ZipFile second) {
		super(stream);
		if(stream == null) {
			throw new NullPointerException("Delegate stream was passed null");	// NOPMD - fail early here with NullPointerException to show where the null value is coming from
		}
		this.zipFile = second;
	}

	@Override
	public void close() throws IOException {
		super.close();

		zipFile.close();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy