Class WebUtils

java.lang.Object
me.hsgamer.hscore.web.WebUtils

public final class WebUtils extends Object
Methods on web
  • Method Details

    • createConnection

      @NotNull public static @NotNull URLConnection createConnection(@NotNull @NotNull String address) throws IOException
      Create a new connection
      Parameters:
      address - the address / URL
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • createConnection

      @NotNull public static @NotNull URLConnection createConnection(@NotNull @NotNull String address, Consumer<URLConnection> connectionConsumer) throws IOException
      Create a new connection
      Parameters:
      address - the address / URL
      connectionConsumer - the consumer to set the connection
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • createHttpConnection

      @NotNull public static @NotNull HttpURLConnection createHttpConnection(@NotNull @NotNull String address) throws IOException
      Create a new HTTP connection
      Parameters:
      address - the address / URL
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • createHttpConnection

      @NotNull public static @NotNull HttpURLConnection createHttpConnection(@NotNull @NotNull String address, Consumer<HttpURLConnection> connectionConsumer) throws IOException
      Create a new HTTP connection
      Parameters:
      address - the address / URL
      connectionConsumer - the consumer to set the connection
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • createHttpsConnection

      @NotNull public static @NotNull HttpsURLConnection createHttpsConnection(@NotNull @NotNull String address) throws IOException
      Create a new HTTPS connection
      Parameters:
      address - the address / URL
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • createHttpsConnection

      @NotNull public static @NotNull HttpsURLConnection createHttpsConnection(@NotNull @NotNull String address, Consumer<HttpsURLConnection> connectionConsumer) throws IOException
      Create a new HTTPS connection
      Parameters:
      address - the address / URL
      connectionConsumer - the consumer to set the connection
      Returns:
      the connection
      Throws:
      IOException - If the URL is invalid or can't be connected
    • encodeUrl

      @NotNull public static @NotNull String encodeUrl(@NotNull @NotNull String string)
      Encode the string
      Parameters:
      string - the string
      Returns:
      the encoded string
    • decodeUrl

      @NotNull public static @NotNull String decodeUrl(@NotNull @NotNull String string)
      Decode the string
      Parameters:
      string - the string
      Returns:
      the decoded string
    • makeUrl

      @NotNull public static @NotNull String makeUrl(@NotNull @NotNull String address, @NotNull @NotNull Map<String,String> queryMap)
      Make a URL with the address and the query map
      Parameters:
      address - the address
      queryMap - the query map
      Returns:
      the URL