Package me.hsgamer.hscore.web
Class WebUtils
java.lang.Object
me.hsgamer.hscore.web.WebUtils
Methods on web
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull URLConnection
createConnection
(@NotNull String address) Create a new connectionstatic @NotNull URLConnection
createConnection
(@NotNull String address, Consumer<URLConnection> connectionConsumer) Create a new connectionstatic @NotNull HttpURLConnection
createHttpConnection
(@NotNull String address) Create a new HTTP connectionstatic @NotNull HttpURLConnection
createHttpConnection
(@NotNull String address, Consumer<HttpURLConnection> connectionConsumer) Create a new HTTP connectionstatic @NotNull HttpsURLConnection
createHttpsConnection
(@NotNull String address) Create a new HTTPS connectionstatic @NotNull HttpsURLConnection
createHttpsConnection
(@NotNull String address, Consumer<HttpsURLConnection> connectionConsumer) Create a new HTTPS connectionstatic @NotNull String
Decode the stringstatic @NotNull String
Encode the stringstatic @NotNull String
Make a URL with the address and the query map
-
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 / URLconnectionConsumer
- 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 / URLconnectionConsumer
- 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 / URLconnectionConsumer
- the consumer to set the connection- Returns:
- the connection
- Throws:
IOException
- If the URL is invalid or can't be connected
-
encodeUrl
Encode the string- Parameters:
string
- the string- Returns:
- the encoded string
-
decodeUrl
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 addressqueryMap
- the query map- Returns:
- the URL
-