Package org.pf4j.util
Class FileUtils
java.lang.Object
org.pf4j.util.FileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Delete a file or recursively delete a folder, do not follow symlinks.static Path
expandIfZip
(Path filePath) Unzip a zip file in a directory that has the same name as the zip file.static Path
static Path
findWithEnding
(Path basePath, String... endings) Finds a path with various endings or null if not found.private static FileSystem
getFileSystem
(URI uri) private static void
static Path
static Path
static boolean
Return true only if path is a jar file.static boolean
Return true only if path is a zip file.static void
optimisticDelete
(Path path) Delete a file (not recursively) and ignore any errors.static void
writeLines
(Collection<String> lines, File file) Deprecated.static void
writeLines
(Collection<String> lines, Path path)
-
Field Details
-
log
private static final org.slf4j.Logger log
-
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
readLines
- Throws:
IOException
-
writeLines
Deprecated.UsewriteLines(Collection, Path)
instead.- Throws:
IOException
-
writeLines
- Throws:
IOException
-
delete
Delete a file or recursively delete a folder, do not follow symlinks.- Parameters:
path
- the file or folder to delete- Throws:
IOException
- if something goes wrong
-
getJars
-
getJars
-
findWithEnding
Finds a path with various endings or null if not found.- Parameters:
basePath
- the base nameendings
- a list of endings to search for- Returns:
- new path or null if not found
-
optimisticDelete
Delete a file (not recursively) and ignore any errors.- Parameters:
path
- the path to delete
-
expandIfZip
Unzip a zip file in a directory that has the same name as the zip file. For example if the zip file ismy-plugin.zip
then the resulted directory ismy-plugin
.- Parameters:
filePath
- the file to evaluate- Returns:
- Path of unzipped folder or original path if this was not a zip file
- Throws:
IOException
- on error
-
isZipFile
Return true only if path is a zip file.- Parameters:
path
- to a file/dir- Returns:
- true if file with
.zip
ending
-
isJarFile
Return true only if path is a jar file.- Parameters:
path
- to a file/dir- Returns:
- true if file with
.jar
ending
-
getPath
- Throws:
IOException
-
getPath
- Throws:
IOException
-
findFile
-
getFileSystem
- Throws:
IOException
-