public final class Util extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static byte[] |
EMPTY_BYTE_ARRAY |
static Headers |
EMPTY_HEADERS |
static RequestBody |
EMPTY_REQUEST |
static ResponseBody |
EMPTY_RESPONSE |
static String[] |
EMPTY_STRING_ARRAY |
static Comparator<String> |
NATURAL_ORDER |
static TimeZone |
UTC
GMT and UTC are equivalent for our purposes.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addSuppressedIfPossible(Throwable e,
Throwable suppressed) |
static Charset |
bomAwareCharset(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(Source source,
int timeout,
TimeUnit timeUnit)
Attempts to exhaust
source, returning true if successful. |
static String |
format(String format,
Object... args)
|
static String |
getSystemProperty(String key,
String defaultValue)
Returns the system property, or defaultValue if the system property is null or cannot be read
(e.g. because of security policy restrictions).
|
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 <K,V> Map<K,V> |
immutableMap(Map<K,V> map)
Returns an immutable copy of
map. |
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 |