- java.lang.Object
-
- org.refcodes.io.ZipUtility
-
public class ZipUtility extends Object
Utility class for some ZIP compression related issues.
-
-
Constructor Summary
Constructors Constructor Description ZipUtility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
toFileNameFromZip(String aZipFileName)
Truncates the ".zip" suffix from the filename and returns the result.static InputStream
toInputStream(File aFile)
Returns anInputStream
from the providedFile
.
-
-
-
Method Detail
-
toInputStream
public static InputStream toInputStream(File aFile) throws ZipException, IOException, 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:
ZipException
- in case there were problems when accessing the ZIP compressedFile
.IOException
- in case there were problems working with theFile
.FileNotFoundException
- in case there was none suchFile
found.
-
toFileNameFromZip
public static String toFileNameFromZip(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.
-
-