Package dev.prozilla.pine.common.system
Class FileSystem
java.lang.Object
dev.prozilla.pine.common.system.FileSystem
Utility class for manipulating files and directories.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyDirectory(File source, File target) Helper method for copying a directory and its contents recursively.static voiddeleteDirectory(Path directory) Deletes a directory and its contents.static booleandeleteDirectoryIfExists(Path directory) Deletes a directory and its contents, if it exists.static voidDownloads a URL into a target directory.static PathgetSubdirectory(Path directory) static voidunwrapDirectory(Path directory) Moves the contents of a directory one level up and deletes the directory.static voidUnzips a zip file into a target directory and deletes it.static voidCreates a zip of the contents of a directory.
-
Method Details
-
deleteDirectoryIfExists
Deletes a directory and its contents, if it exists.- Parameters:
directory- The directory to delete- Returns:
trueif the directory was deleted.
-
deleteDirectory
Deletes a directory and its contents.- Parameters:
directory- The directory to delete
-
copyDirectory
Helper method for copying a directory and its contents recursively.- Parameters:
source- The directory to copy fromtarget- The directory to paste into- Throws:
IOException
-
getSubdirectory
- Throws:
IOException
-
unwrapDirectory
Moves the contents of a directory one level up and deletes the directory.- Parameters:
directory- The directory to unwrap- Throws:
IOException
-
download
Downloads a URL into a target directory.- Parameters:
url- The URL to download fromtarget- The path to download to- Throws:
URISyntaxExceptionIOException
-
unzip
Unzips a zip file into a target directory and deletes it.- Parameters:
zip- The zip to unziptarget- The path to unzip into- Throws:
IOException
-
zip
Creates a zip of the contents of a directory. The zip file is placed inside the same directory.- Parameters:
directory- The directory to create a zip offileName- The filename to use for the zip file- Throws:
IOException
-