Package org.refcodes.io
Class ZipFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.BufferedInputStream
-
- org.refcodes.io.ZipFileInputStream
-
public class ZipFileInputStream extends java.io.BufferedInputStream
Represents anInputStream
from a providedFile
: In case the file points to a ZIP compressed file, then the uncompressed data of the therein contained file with the same name excluding the ".zip" extension is provided by theInputStream
.
-
-
Constructor Summary
Constructors Constructor Description ZipFileInputStream(java.io.File aFile)
Instantiates a new zip file input stream impl.ZipFileInputStream(java.io.File parent, java.lang.String child)
Instantiates a new zip file input stream impl.ZipFileInputStream(java.lang.String pathname)
Instantiates a new zip file input stream impl.ZipFileInputStream(java.lang.String parent, java.lang.String child)
Instantiates a new zip file input stream impl.ZipFileInputStream(java.net.URI uri)
Instantiates a new zip file input stream impl.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
toFileNameFromZip(java.lang.String aZipFileName)
Truncates the ".zip" suffix from the filename and returns the result.protected static java.io.InputStream
toInputStream(java.io.File aFile)
Returns anInputStream
from the providedFile
.
-
-
-
Constructor Detail
-
ZipFileInputStream
public ZipFileInputStream(java.io.File parent, java.lang.String child) throws java.util.zip.ZipException, java.io.FileNotFoundException, java.io.IOException
Instantiates a new zip file input stream impl.- Parameters:
parent
- the parentchild
- the child- Throws:
java.util.zip.ZipException
- the zip exceptionjava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
ZipFileInputStream
public ZipFileInputStream(java.lang.String parent, java.lang.String child) throws java.util.zip.ZipException, java.io.FileNotFoundException, java.io.IOException
Instantiates a new zip file input stream impl.- Parameters:
parent
- the parentchild
- the child- Throws:
java.util.zip.ZipException
- the zip exceptionjava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
ZipFileInputStream
public ZipFileInputStream(java.lang.String pathname) throws java.util.zip.ZipException, java.io.FileNotFoundException, java.io.IOException
Instantiates a new zip file input stream impl.- Parameters:
pathname
- the pathname- Throws:
java.util.zip.ZipException
- the zip exceptionjava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
ZipFileInputStream
public ZipFileInputStream(java.net.URI uri) throws java.util.zip.ZipException, java.io.FileNotFoundException, java.io.IOException
Instantiates a new zip file input stream impl.- Parameters:
uri
- the uri- Throws:
java.util.zip.ZipException
- the zip exceptionjava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
ZipFileInputStream
public ZipFileInputStream(java.io.File aFile) throws java.util.zip.ZipException, java.io.FileNotFoundException, java.io.IOException
Instantiates a new zip file input stream impl.- Parameters:
aFile
- the file- Throws:
java.util.zip.ZipException
- the zip exceptionjava.io.FileNotFoundException
- the file not found exceptionjava.io.IOException
- Signals that an I/O exception has occurred.
-
-
Method Detail
-
toInputStream
protected static java.io.InputStream toInputStream(java.io.File aFile) throws java.util.zip.ZipException, java.io.IOException, java.io.FileNotFoundException
Returns anInputStream
from the providedFile
. In case the file points to a ZIP compressed file, then the uncompressed data is provided by theInputStream
.- Parameters:
aFile
- TheFile
for which to get theInputStream
.- Returns:
- An
InputStream
, in case of a ZIP compressedFile
, an uncompressedInputStream
is returned. - Throws:
java.util.zip.ZipException
- in case there were problems when accessing the ZIP compressedFile
.java.io.IOException
- in case there were problems working with theFile
.java.io.FileNotFoundException
- in case there was none suchFile
found.
-
toFileNameFromZip
protected static java.lang.String toFileNameFromZip(java.lang.String aZipFileName)
Truncates the ".zip" suffix from the filename and returns the result. For example a file with name "log-2023-07-12.txt.zip" results in "log-2023-07-12.txt".- Parameters:
aZipFileName
- The file name of the ZIP file for which to get the "inner" file name.- Returns:
- The "inner" file name if the file suffix was ".zip", else null.
-
-