Class DownloadUtil

java.lang.Object
net.fabricmc.loom.util.DownloadUtil

public class DownloadUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    delete​(File file)
    Delete the file along with the corresponding ETag, if it exists.
    static void
    downloadIfChanged​(URL from, File to, org.gradle.api.logging.Logger logger)
    Download from the given URL to the given File so long as there are differences between them.
    static void
    downloadIfChanged​(URL from, File to, org.gradle.api.logging.Logger logger, boolean quiet)
    Download from the given URL to the given File so long as there are differences between them.
    static String
    toNiceSize​(long bytes)
    Format the given number of bytes as a more human readable string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DownloadUtil

      public DownloadUtil()
  • Method Details

    • downloadIfChanged

      public static void downloadIfChanged​(URL from, File to, org.gradle.api.logging.Logger logger) throws IOException
      Download from the given URL to the given File so long as there are differences between them.
      Parameters:
      from - The URL of the file to be downloaded
      to - The destination to be saved to, and compared against if it exists
      logger - The logger to print everything to, typically from Project.getLogger()
      Throws:
      IOException - If an exception occurs during the process
    • downloadIfChanged

      public static void downloadIfChanged​(URL from, File to, org.gradle.api.logging.Logger logger, boolean quiet) throws IOException
      Download from the given URL to the given File so long as there are differences between them.
      Parameters:
      from - The URL of the file to be downloaded
      to - The destination to be saved to, and compared against if it exists
      logger - The logger to print information to, typically from Project.getLogger()
      quiet - Whether to only print warnings (when true) or everything
      Throws:
      IOException - If an exception occurs during the process
    • toNiceSize

      public static String toNiceSize​(long bytes)
      Format the given number of bytes as a more human readable string.
      Parameters:
      bytes - The number of bytes
      Returns:
      The given number of bytes formatted to kilobytes, megabytes or gigabytes if appropriate
    • delete

      public static void delete​(File file)
      Delete the file along with the corresponding ETag, if it exists.
      Parameters:
      file - The file to delete.