Package org.assertj.core.util
Class URLs
- java.lang.Object
-
- org.assertj.core.util.URLs
-
public class URLs extends Object
Utility methods related to URLs.- Author:
- Turbo87, dorzey
-
-
Constructor Summary
Constructors Modifier Constructor Description private
URLs()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
checkArgumentCharsetIsSupported(String charsetName)
static String
contentOf(URL url, String charsetName)
Loads the text content of a URL into a character string.static String
contentOf(URL url, Charset charset)
Loads the text content of a URL into a character string.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.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.private static String
loadContents(InputStream stream, Charset charset)
private static List<String>
loadLines(InputStream stream, Charset charset)
-
-
-
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 isnull
.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 isnull
.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 isnull
.UncheckedIOException
- if an I/O exception occurs.
-
loadContents
private static String loadContents(InputStream stream, Charset charset) throws IOException
- Throws:
IOException
-
loadLines
private static List<String> loadLines(InputStream stream, Charset charset) throws IOException
- Throws:
IOException
-
checkArgumentCharsetIsSupported
private static void checkArgumentCharsetIsSupported(String charsetName)
-
-