Package org.goplanit.utils.zip
Class PlanitZipFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.goplanit.utils.zip.PlanitZipFileInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class PlanitZipFileInputStream extends InputStream
A wrapper around a ZipFile's InputStream that keeps the underlying file open while an entry is being streamed. Useful when creating a the zip file stream in one location and we want to return it to another location without the underlying file being closed- Author:
- markr
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PlanitZipFileInputStream(ZipFile zipFile, ZipEntry entry)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
close the streamsstatic PlanitZipFileInputStream
of(ZipFile zipFile, ZipEntry entry)
create PLANit zip input stream containing all input streams that need to remain in scope for the input stream to be accessibleint
read()
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
PlanitZipFileInputStream
protected PlanitZipFileInputStream(ZipFile zipFile, ZipEntry entry) throws IOException
Constructor- Parameters:
zipFile
- the stream originates fromentry
- to base stream on- Throws:
IOException
- thrown if error
-
-
Method Detail
-
of
public static PlanitZipFileInputStream of(ZipFile zipFile, ZipEntry entry) throws IOException
create PLANit zip input stream containing all input streams that need to remain in scope for the input stream to be accessible- Parameters:
zipFile
- to useentry
- to base stream on- Returns:
- zip file input stream
- Throws:
IOException
- thrown if error
-
close
public void close() throws IOException
close the streams- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- thrown if error
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
-