Class URLs


  • public class URLs
    extends Object
    Utility methods related to URLs.
    Author:
    Turbo87, dorzey
    • Constructor Detail

      • URLs

        private URLs()
    • Method Detail

      • contentOf

        public static String contentOf​(URL url,
                                       String charsetName)
        Loads the text content of a URL into a character string.
        Parameters:
        url - the URL.
        charsetName - the name of the character set to use.
        Returns:
        the content of the file.
        Throws:
        IllegalArgumentException - if the given character set is not supported on this platform.
        UncheckedIOException - if an I/O exception occurs.
      • contentOf

        public static String contentOf​(URL url,
                                       Charset charset)
        Loads the text content of a URL into a character string.
        Parameters:
        url - the URL.
        charset - the character set to use.
        Returns:
        the content of the URL.
        Throws:
        NullPointerException - if the given charset is null.
        UncheckedIOException - if an I/O exception occurs.
      • linesOf

        public static List<String> linesOf​(URL url,
                                           Charset charset)
        Loads the text content of a URL into a list of strings, each string corresponding to a line. The line endings are either \n, \r or \r\n.
        Parameters:
        url - the URL.
        charset - the character set to use.
        Returns:
        the content of the URL.
        Throws:
        NullPointerException - if the given charset is null.
        UncheckedIOException - if an I/O exception occurs.
      • linesOf

        public static List<String> linesOf​(URL url,
                                           String charsetName)
        Loads the text content of a URL into a list of strings, each string corresponding to a line. The line endings are either \n, \r or \r\n.
        Parameters:
        url - the URL.
        charsetName - the name of the character set to use.
        Returns:
        the content of the URL.
        Throws:
        NullPointerException - if the given charset is null.
        UncheckedIOException - if an I/O exception occurs.
      • checkArgumentCharsetIsSupported

        private static void checkArgumentCharsetIsSupported​(String charsetName)