public class Zips extends Object
| Constructor and Description |
|---|
Zips() |
| Modifier and Type | Method and Description |
|---|---|
static void |
createDirectoryIfNecessary(File dir) |
static boolean |
isZipFile(File file)
Tests if the given file is a zip file.
|
static void |
uncompress(InputStream stream,
File targetDir)
Uncompress zipped stream in targetDir.
|
static void |
uncompressAndRename(InputStream stream,
File targetDir,
String renameFrom,
String renameTo)
Uncompress zipped stream in targetDir, and rename uncompressed file if
necessary.
|
static void |
uncompressFiltred(File file,
File targetDir,
String... excludes)
Unzip compressed archive and keep non excluded patterns.
|
public static void uncompress(InputStream stream, File targetDir) throws IOException
stream - the zip source stream, stream is closed before returntargetDir - the destination directoryIOException - if any problem while unzippublic static void uncompressAndRename(InputStream stream, File targetDir, String renameFrom, String renameTo) throws IOException
file in zip use / to separate directory and not begin with / each directory ended with /
stream - the zip source stream, stream is closed before returntargetDir - the destination directoryrenameFrom - pattern to permit rename file before uncompress itrenameTo - new name for file if renameFrom is applicable to it
you can use $1, $2, ... if you have '(' ')' in renameFromIOException - if any problem while uncompressingpublic static void uncompressFiltred(File file, File targetDir, String... excludes) throws IOException
file - archive filetargetDir - destination fileexcludes - excludes pattern (pattern must match complete entry name including root folder)IOException - FIXMEpublic static void createDirectoryIfNecessary(File dir)
public static boolean isZipFile(File file)
file - the file to testtrue if the file is a valid zip file,
false otherwise.Copyright © 2018–2019 Ultreia.io. All rights reserved.