public final class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.reflect.Method |
addSuppressedExceptionMethod |
static byte[] |
EMPTY_BYTE_ARRAY |
static Headers |
EMPTY_HEADERS |
static RequestBody |
EMPTY_REQUEST |
static ResponseBody |
EMPTY_RESPONSE |
static java.lang.String[] |
EMPTY_STRING_ARRAY |
static java.util.Comparator<java.lang.String> |
NATURAL_ORDER |
private static okio.Options |
UNICODE_BOMS
Byte order marks.
|
static java.util.TimeZone |
UTC
GMT and UTC are equivalent for our purposes.
|
private static java.nio.charset.Charset |
UTF_32BE |
private static java.nio.charset.Charset |
UTF_32LE |
private static java.util.regex.Pattern |
VERIFY_AS_IP_ADDRESS
Quick and dirty pattern to differentiate IP addresses from hostnames.
|
Modifier | Constructor and Description |
---|---|
private |
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
addSuppressedIfPossible(java.lang.Throwable e,
java.lang.Throwable suppressed) |
static java.nio.charset.Charset |
bomAwareCharset(okio.BufferedSource source,
java.nio.charset.Charset charset) |
static java.lang.String |
canonicalizeHost(java.lang.String host)
If
host is an IP address, this returns the IP address in canonical form. |
static int |
checkDuration(java.lang.String name,
long duration,
java.util.concurrent.TimeUnit unit) |
static void |
checkOffsetAndCount(long arrayLength,
long offset,
long count) |
static void |
closeQuietly(java.io.Closeable closeable)
Closes
closeable , ignoring any checked exceptions. |
static void |
closeQuietly(java.net.ServerSocket serverSocket)
Closes
serverSocket , ignoring any checked exceptions. |
static void |
closeQuietly(java.net.Socket socket)
Closes
socket , ignoring any checked exceptions. |
static java.lang.String[] |
concat(java.lang.String[] array,
java.lang.String value) |
private static boolean |
containsInvalidHostnameAsciiCodes(java.lang.String hostnameAscii) |
static int |
decodeHexDigit(char c) |
private static boolean |
decodeIpv4Suffix(java.lang.String input,
int pos,
int limit,
byte[] address,
int addressOffset)
Decodes an IPv4 address suffix of an IPv6 address, like 1111::5555:6666:192.168.0.1.
|
private static java.net.InetAddress |
decodeIpv6(java.lang.String input,
int pos,
int limit)
Decodes an IPv6 address like 1111:2222:3333:4444:5555:6666:7777:8888 or ::1.
|
static int |
delimiterOffset(java.lang.String input,
int pos,
int limit,
char delimiter)
Returns the index of the first character in
input that is delimiter . |
static int |
delimiterOffset(java.lang.String input,
int pos,
int limit,
java.lang.String delimiters)
Returns the index of the first character in
input that contains a character in delimiters . |
static boolean |
discard(okio.Source source,
int timeout,
java.util.concurrent.TimeUnit timeUnit)
Attempts to exhaust
source , returning true if successful. |
static java.lang.String |
format(java.lang.String format,
java.lang.Object... args)
Returns a
Locale.US formatted String . |
static java.lang.String |
getSystemProperty(java.lang.String key,
java.lang.String defaultValue)
Returns the system property, or defaultValue if the system property is null or
cannot be read (e.g.
|
static java.lang.String |
hostHeader(HttpUrl url,
boolean includeDefaultPort) |
static <T> java.util.List<T> |
immutableList(java.util.List<T> list)
Returns an immutable copy of
list . |
static <T> java.util.List<T> |
immutableList(T... elements)
Returns an immutable list containing
elements . |
static <K,V> java.util.Map<K,V> |
immutableMap(java.util.Map<K,V> map)
Returns an immutable copy of
map . |
static int |
indexOf(java.util.Comparator<java.lang.String> comparator,
java.lang.String[] array,
java.lang.String value) |
static int |
indexOfControlOrNonAscii(java.lang.String input)
Returns the index of the first character in input that is either a control character
(like
|