Class URLUtils

java.lang.Object
de.murmelmeister.library.utils.URLUtils

public final class URLUtils extends Object
Utility class for handling URL-related operations. Provides methods to fetch content from a URL as a string.
  • Constructor Details

    • URLUtils

      public URLUtils()
  • Method Details

    • getText

      public static String getText(String url) throws IOException, URISyntaxException
      Fetches the content of the resource located at the specified URL as a string. Opens an HTTP connection to the given URL, retrieves the response content, and returns it as a string. In the case of an error response, the error stream content is returned.
      Parameters:
      url - The URL of the resource to fetch content from
      Returns:
      The content of the resource as a string
      Throws:
      IOException - If an I/O exception occurs while opening the connection or reading from it
      URISyntaxException - If the provided URL is not a valid URI