Package me.deecaad.core.utils
Class FileUtil
java.lang.Object
me.deecaad.core.utils.FileUtil
This final utility class outlines static methods that work with files, resources, and streams.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyResourcesTo(URL source, Path target) Copies the resource defined byresourcein the project's resource folder to anoutputdirectory.static voiddownloadFile(File target, String link, int connectionTime, int readTime) static voidensureDefaults(URL resource, File file) Ensures that a givenfilehas all config options defined by theresource.static voidensureFile(URL resource, File file) getJarFile(org.bukkit.plugin.Plugin plugin, File jar) Returns the jar file from the given arguments.
-
Method Details
-
copyResourcesTo
Copies the resource defined byresourcein the project's resource folder to anoutputdirectory. If the copied resource is a folder (If the file name does not contain a '.'), then this method will be called recursively until all subdirectories are copied.- Parameters:
source- The non-null resource folder that contains the files to copy. No need to start this with a '/' character. Depending on the .jar file, you may need to append 'resources/' before your resource. UseClassLoader.getResource(String).target- The non-null target file to write all the resource files to. UseFile.toPath().- Throws:
InternalError- If an IO or URI exception occurs.
-
getJarFile
Returns the jar file from the given arguments. The file should point to a.jarfile. You can get theFilefrom your plugin using the protected JavaPlugin#getFile() method.- Parameters:
plugin- The non-null plugin who owns the jar file.jar- The non-null file pointing to the jar- Returns:
- The non-null jar file.
-
ensureDefaults
Ensures that a givenfilehas all config options defined by theresource.- Parameters:
resource- The non-null resource to copy.file- The output file that should have the default values.
-
downloadFile
-
ensureFile
-