Package org.pf4j.util
Class FileUtils
java.lang.Object
org.pf4j.util.FileUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidDelete a file or recursively delete a folder, do not follow symlinks.static PathexpandIfZip(Path filePath) Unzip a zip file in a directory that has the same name as the zip file.static Pathstatic PathfindWithEnding(Path basePath, String... endings) Finds a path with various endings or null if not found.private static FileSystemgetFileSystem(URI uri) private static voidstatic Pathstatic Pathstatic booleanReturn true only if path is a jar file.static booleanReturn true only if path is a zip file.static voidoptimisticDelete(Path path) Delete a file (not recursively) and ignore any errors.static voidwriteLines(Collection<String> lines, File file) Deprecated.static voidwriteLines(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.zipthen 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
.zipending
-
isJarFile
Return true only if path is a jar file.- Parameters:
path- to a file/dir- Returns:
- true if file with
.jarending
-
getPath
- Throws:
IOException
-
getPath
- Throws:
IOException
-
findFile
-
getFileSystem
- Throws:
IOException
-