Class URLUtils

java.lang.Object
ml.karmaconfigs.api.common.utils.URLUtils

public final class URLUtils extends Object
Karma URL utilities
  • Constructor Details

    • URLUtils

      public URLUtils()
  • Method Details

    • fastConnect

      public static void fastConnect(URL url)
      Connect and instantly disconnect from a URL. This method may be called only when actually needed
      Parameters:
      url - the url to connect
    • exists

      public static boolean exists(String url)
      Get if the URL exists
      Parameters:
      url - the url
      Returns:
      if the url exists
    • getResponseCode

      public static int getResponseCode(String url)
      Get the URL response code
      Parameters:
      url - the url
      Returns:
      the URL response code
    • getOrNull

      @Nullable public static @Nullable URL getOrNull(String url)
      Get the URL or null if couldn't retrieve specified URL
      Parameters:
      url - the url
      Returns:
      the url or null
    • getOrBackup

      @Nullable public static @Nullable URL getOrBackup(String def, String... backup)
      Get the url or default
      Parameters:
      def - the default url
      backup - the backup urls
      Returns:
      the url or defaults
    • getResponse

      public static String getResponse(URL url)
      Get the web response
      Parameters:
      url - the url to fetch response from
      Returns:
      the web response or empty