public class FileUtils
extends java.lang.Object
| Constructor and Description |
|---|
FileUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
deleteFolder(java.io.File folder)
Deletes a folder and all its content
|
static java.io.File |
downloadFile(java.lang.String url,
java.io.File output)
Downloads a file from the internet and saves it to the given output file.
|
static java.io.File |
downloadFile(java.lang.String url,
java.lang.String agent,
java.io.File output)
Downloads a file from the internet and saves it to the given output file.
|
static void |
extractFile(java.util.zip.ZipInputStream zipIn,
java.lang.String filePath)
Extracts a file from the given zip input stream to the given file path.
|
static void |
unzip(java.lang.String zipFilePath,
java.lang.String destDirectory)
Unzips the given zip file to the given target directory.
|
static void |
unzipFolder(java.io.File source,
java.nio.file.Path target)
Unzips the given zip file to the given target directory.
|
static java.nio.file.Path |
zipSlipProtect(java.util.zip.ZipEntry zipEntry,
java.nio.file.Path targetDir)
Protects against zip slip vulnerability.
|
public static java.io.File downloadFile(java.lang.String url,
java.io.File output)
throws java.lang.Throwable
url - The url to download the file from.output - The file to save the downloaded file to.java.lang.Throwable - If an error occurs while downloading the file.public static java.io.File downloadFile(java.lang.String url,
java.lang.String agent,
java.io.File output)
throws java.lang.Throwable
url - The url to download the file from.agent - The user agent to use.output - The file to save the downloaded file to.java.lang.Throwable - If an error occurs while downloading the file.public static void unzipFolder(java.io.File source,
java.nio.file.Path target)
throws java.io.IOException
source - the zip filetarget - the target directoryjava.io.IOException - if an I/O error occurspublic static void unzip(java.lang.String zipFilePath,
java.lang.String destDirectory)
throws java.io.IOException
zipFilePath - the zip filedestDirectory - the target directoryjava.io.IOException - if an I/O error occurspublic static void extractFile(java.util.zip.ZipInputStream zipIn,
java.lang.String filePath)
throws java.io.IOException
zipIn - the zip input streamfilePath - the file pathjava.io.IOException - if an I/O error occurspublic static java.nio.file.Path zipSlipProtect(java.util.zip.ZipEntry zipEntry,
java.nio.file.Path targetDir)
throws java.io.IOException
zipEntry - the zip entrytargetDir - the target directoryjava.io.IOException - if an I/O error occurspublic static void deleteFolder(java.io.File folder)
throws java.io.IOException
folder - the folder to deletejava.io.IOException - if an I/O error occurs