public final class Util extends Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static RequestBody |
EMPTY_REQUEST |
static ResponseBody |
EMPTY_RESPONSE |
static String[] |
EMPTY_STRING_ARRAY |
static Charset |
ISO_8859_1 |
static Comparator<String> |
NATURAL_ORDER |
static TimeZone |
UTC
GMT and UTC are equivalent for our purposes.
|
static Charset |
UTF_8 |
Modifier and Type | Method and Description |
---|---|
static AssertionError |
assertionError(String message,
Exception e) |
static Charset |
bomAwareCharset(okio.BufferedSource source,
Charset charset) |
static String |
canonicalizeHost(String host)
If
host is an IP address, this returns the IP address in canonical form. |
static int |
checkDuration(String name,
long duration,
TimeUnit unit) |
static void |
checkOffsetAndCount(long arrayLength,
long offset,
long count) |
static void |
closeQuietly(Closeable closeable)
Closes
closeable , ignoring any checked exceptions. |
static void |
closeQuietly(ServerSocket serverSocket)
Closes
serverSocket , ignoring any checked exceptions. |
static void |
closeQuietly(Socket socket)
Closes
socket , ignoring any checked exceptions. |
static String[] |
concat(String[] array,
String value) |
static int |
decodeHexDigit(char c) |
static int |
delimiterOffset(String input,
int pos,
int limit,
char delimiter)
Returns the index of the first character in
input that is delimiter . |
static int |
delimiterOffset(String input,
int pos,
int limit,
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,
TimeUnit timeUnit)
Attempts to exhaust
source , returning true if successful. |
static boolean |
equal(Object a,
Object b)
Returns true if two possibly-null objects are equal.
|
static String |
format(String format,
Object... args)
|
static String |
hostHeader(HttpUrl url,
boolean includeDefaultPort) |
static <T> List<T> |
immutableList(List<T> list)
Returns an immutable copy of
list . |
static <T> List<T> |
immutableList(T... elements)
Returns an immutable list containing
elements . |
static int |
indexOf(Comparator<String> comparator,
String[] array,
String value) |
static int |
indexOfControlOrNonAscii(String input)
Returns the index of the first character in input that is either a control character
(like
|