Package org.geysermc.geyser.util
Class WebUtils
java.lang.Object
org.geysermc.geyser.util.WebUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddownloadFile(String reqURL, String fileLocation)Downloads a file from the given URL and saves it to diskstatic StringMakes a web request to the given URL and returns the body as a stringstatic com.fasterxml.jackson.databind.JsonNodeMakes a web request to the given URL and returns the body as aJsonNode.static StringPost a string to the given URLstatic StringPost fields to a URL as a form
-
Constructor Details
-
WebUtils
public WebUtils()
-
-
Method Details
-
getBody
Makes a web request to the given URL and returns the body as a string- Parameters:
reqURL- URL to fetch- Returns:
- Body contents or error message if the request fails
-
getJson
Makes a web request to the given URL and returns the body as aJsonNode.- Parameters:
reqURL- URL to fetch- Returns:
- the response as JSON
- Throws:
IOException
-
downloadFile
Downloads a file from the given URL and saves it to disk- Parameters:
reqURL- File to fetchfileLocation- Location to save on disk
-
post
Post a string to the given URL- Parameters:
reqURL- URL to post topostContent- String data to post- Returns:
- String returned by the server
- Throws:
IOException
-
postForm
Post fields to a URL as a form- Parameters:
reqURL- URL to post tofields- Form data to post- Returns:
- String returned by the server
- Throws:
IOException
-