Class FileUtil

java.lang.Object
me.deecaad.core.utils.FileUtil

public final class FileUtil extends Object
This final utility class outlines static methods that work with files, resources, and streams.
  • Method Details

    • copyResourcesTo

      public static void copyResourcesTo(URL source, Path target)
      Copies the resource defined by resource in the project's resource folder to an output directory. 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. Use ClassLoader.getResource(String).
      target - The non-null target file to write all the resource files to. Use File.toPath().
      Throws:
      InternalError - If an IO or URI exception occurs.
    • getJarFile

      public JarFile getJarFile(org.bukkit.plugin.Plugin plugin, File jar)
      Returns the jar file from the given arguments. The file should point to a .jar file. You can get the File from 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

      public static void ensureDefaults(URL resource, File file)
      Ensures that a given file has all config options defined by the resource.
      Parameters:
      resource - The non-null resource to copy.
      file - The output file that should have the default values.
    • downloadFile

      public static void downloadFile(File target, String link, int connectionTime, int readTime)
    • ensureFile

      public static void ensureFile(URL resource, File file)