org.redkale.util

## 类 Utility

- java.lang.Object
- - org.redkale.util.Utility

-     public final class Utility
      extends java.lang.Object

  详情见: https://redkale.org

- - ### 方法概要

    所有方法 静态方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `static char[]` | `binToHex(byte[] bytes)`
    `static char[]` | `binToHex(byte[] bytes, int offset, int len)`
    `static java.lang.String` | `binToHexString(byte[] bytes)`
    `static java.lang.String` | `binToHexString(byte[] bytes, int offset, int len)`
    `static char[]` | `charArray(java.lang.String value)`
    `static char[]` | `charArray(java.lang.StringBuilder value)`
    `static java.net.Socket` | `createDefaultSSLSocket(java.net.InetAddress host, int port)`
    `static java.net.Socket` | `createDefaultSSLSocket(java.net.InetSocketAddress address)`
    `static char[]` | `decodeUTF8(byte[] array)`
    `static char[]` | `decodeUTF8(byte[] array, int start, int len)`
    `static java.nio.ByteBuffer` | `encodeUTF8(java.nio.ByteBuffer buffer, char[] array)`
    `static java.nio.ByteBuffer` | `encodeUTF8(java.nio.ByteBuffer buffer, char[] text, int start, int len)`
    `static java.nio.ByteBuffer` | `encodeUTF8(java.nio.ByteBuffer buffer, int bytesLength, char[] array)`
    `static java.nio.ByteBuffer` | `encodeUTF8(java.nio.ByteBuffer buffer, int bytesLength, char[] text, int start, int len)`
    `static byte[]` | `encodeUTF8(char[] array)`
    `static byte[]` | `encodeUTF8(char[] text, int start, int len)`
    `static byte[]` | `encodeUTF8(java.lang.String value)`
    `static int` | `encodeUTF8Length(char[] text)`
    `static int` | `encodeUTF8Length(char[] text, int start, int len)`
    `static int` | `encodeUTF8Length(java.lang.String value)`
    `static java.lang.String` | `format36time(long time)`
    `static java.lang.String` | `formatTime(long time)`
    `static javax.net.ssl.SSLContext` | `getDefaultSSLContext()`
    `static byte[]` | `getHttpBytesContent(javax.net.ssl.SSLContext ctx, java.lang.String url)`
    `static byte[]` | `getHttpBytesContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static byte[]` | `getHttpBytesContent(java.lang.String url)`
    `static byte[]` | `getHttpBytesContent(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `getHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url)`
    `static java.lang.String` | `getHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.nio.charset.Charset charset)`
    `static java.lang.String` | `getHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.nio.charset.Charset charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `getHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `getHttpContent(java.lang.String url)`
    `static java.lang.String` | `getHttpContent(java.lang.String url, java.nio.charset.Charset charset)`
    `static java.lang.String` | `getHttpContent(java.lang.String url, java.nio.charset.Charset charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `getHttpContent(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static byte[]` | `hexToBin(char[] src)`
    `static byte[]` | `hexToBin(char[] src, int offset, int len)`
    `static byte[]` | `hexToBin(java.lang.CharSequence src)`
    `static byte[]` | `hexToBin(java.lang.CharSequence src, int offset, int len)`
    `static byte[]` | `hexToBin(java.lang.String str)`
    `static java.net.InetAddress` | `localInetAddress()` 返回本机的第一个内网IPv4地址， 没有则返回null
    `static long` | `merge(int high, int low)` 将两个数字组装成一个long
    `static long` | `midnight()` 获取当天凌晨零点的格林时间
    `static long` | `midnight(long time)` 获取指定时间当天凌晨零点的格林时间
    `static long` | `monday(long time)` 获取时间点所在星期的周一
    `static long` | `monthFirstDay(long time)` 获取时间点所在月份的1号
    `static java.lang.String` | `now()`
    `static byte[]` | `postHttpBytesContent(javax.net.ssl.SSLContext ctx, java.lang.String url)`
    `static byte[]` | `postHttpBytesContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static byte[]` | `postHttpBytesContent(java.lang.String url)`
    `static byte[]` | `postHttpBytesContent(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.nio.charset.Charset charset)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.nio.charset.Charset charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.nio.charset.Charset charset, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String url, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(java.lang.String url)`
    `static java.lang.String` | `postHttpContent(java.lang.String url, java.nio.charset.Charset charset)`
    `static java.lang.String` | `postHttpContent(java.lang.String url, java.nio.charset.Charset charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(java.lang.String url, java.nio.charset.Charset charset, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.lang.String` | `postHttpContent(java.lang.String url, java.lang.String body)`
    `static void` | `println(java.lang.String string, byte... bytes)`
    `static void` | `println(java.lang.String string, java.nio.ByteBuffer buffer)`
    `static java.lang.String` | `read(java.io.InputStream in)`
    `static java.lang.String` | `read(java.io.InputStream in, java.lang.String charsetName)`
    `static byte[]` | `readBytes(java.io.InputStream in)`
    `static byte[]` | `readBytesThenClose(java.io.InputStream in)`
    `static java.io.ByteArrayOutputStream` | `readStream(java.io.InputStream in)`
    `static java.io.ByteArrayOutputStream` | `readStreamThenClose(java.io.InputStream in)`
    `static java.io.ByteArrayOutputStream` | `remoteHttpContent(javax.net.ssl.SSLContext ctx, java.lang.String method, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static java.io.ByteArrayOutputStream` | `remoteHttpContent(java.lang.String method, java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String body)`
    `static long` | `sunday(long time)` 获取时间点所在星期的周日
    `static int` | `today()` 获取当天20151231格式的int值
    `static java.lang.String` | `toString(java.lang.String string, java.nio.ByteBuffer buffer)`
    `static java.lang.String` | `uuid()`
    `static int` | `yyyyMMdd(long time)` 获取指定时间的20160202格式的int值

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 方法详细资料

    - #### uuid

          public static java.lang.String uuid()

    - #### toString

          public static java.lang.String toString(java.lang.String string,
                                                  java.nio.ByteBuffer buffer)

    - #### println

          public static void println(java.lang.String string,
                                     java.nio.ByteBuffer buffer)

    - #### println

          public static void println(java.lang.String string,
                                     byte... bytes)

    - #### localInetAddress

          public static java.net.InetAddress localInetAddress()

      返回本机的第一个内网IPv4地址， 没有则返回null
      返回:
        IPv4地址

    - #### now

          public static java.lang.String now()

    - #### formatTime

          public static java.lang.String formatTime(long time)

    - #### format36time

          public static java.lang.String format36time(long time)

    - #### midnight

          public static long midnight()

      获取当天凌晨零点的格林时间
      返回:
        毫秒数

    - #### midnight

          public static long midnight(long time)

      获取指定时间当天凌晨零点的格林时间
      参数:
        `time` - 指定时间
      返回:
        毫秒数

    - #### today

          public static int today()

      获取当天20151231格式的int值
      返回:
        20151231格式的int值

    - #### yyyyMMdd

          public static int yyyyMMdd(long time)

      获取指定时间的20160202格式的int值
      参数:
        `time` - 指定时间
      返回:
        毫秒数

    - #### monday

          public static long monday(long time)

      获取时间点所在星期的周一
      参数:
        `time` - 指定时间
      返回:
        毫秒数

    - #### sunday

          public static long sunday(long time)

      获取时间点所在星期的周日
      参数:
        `time` - 指定时间
      返回:
        毫秒数

    - #### monthFirstDay

          public static long monthFirstDay(long time)

      获取时间点所在月份的1号
      参数:
        `time` - 指定时间
      返回:
        毫秒数

    - #### binToHexString

          public static java.lang.String binToHexString(byte[] bytes)

    - #### binToHex

          public static char[] binToHex(byte[] bytes)

    - #### binToHexString

          public static java.lang.String binToHexString(byte[] bytes,
                                                        int offset,
                                                        int len)

    - #### binToHex

          public static char[] binToHex(byte[] bytes,
                                        int offset,
                                        int len)

    - #### hexToBin

          public static byte[] hexToBin(java.lang.CharSequence src)

    - #### hexToBin

          public static byte[] hexToBin(java.lang.CharSequence src,
                                        int offset,
                                        int len)

    - #### hexToBin

          public static byte[] hexToBin(java.lang.String str)

    - #### hexToBin

          public static byte[] hexToBin(char[] src)

    - #### hexToBin

          public static byte[] hexToBin(char[] src,
                                        int offset,
                                        int len)

    - #### decodeUTF8

          public static char[] decodeUTF8(byte[] array)

    - #### decodeUTF8

          public static char[] decodeUTF8(byte[] array,
                                          int start,
                                          int len)

    - #### encodeUTF8

          public static byte[] encodeUTF8(java.lang.String value)

    - #### encodeUTF8

          public static byte[] encodeUTF8(char[] array)

    - #### encodeUTF8

          public static byte[] encodeUTF8(char[] text,
                                          int start,
                                          int len)

    - #### charArray

          public static char[] charArray(java.lang.String value)

    - #### charArray

          public static char[] charArray(java.lang.StringBuilder value)

    - #### encodeUTF8

          public static java.nio.ByteBuffer encodeUTF8(java.nio.ByteBuffer buffer,
                                                       char[] array)

    - #### encodeUTF8

          public static java.nio.ByteBuffer encodeUTF8(java.nio.ByteBuffer buffer,
                                                       int bytesLength,
                                                       char[] array)

    - #### encodeUTF8Length

          public static int encodeUTF8Length(java.lang.String value)

    - #### encodeUTF8Length

          public static int encodeUTF8Length(char[] text)

    - #### encodeUTF8Length

          public static int encodeUTF8Length(char[] text,
                                             int start,
                                             int len)

    - #### merge

          public static long merge(int high,
                                   int low)

      将两个数字组装成一个long
      参数:
        `high` - 高位值
        `low` - 低位值
      返回:
        long值

    - #### encodeUTF8

          public static java.nio.ByteBuffer encodeUTF8(java.nio.ByteBuffer buffer,
                                                       char[] text,
                                                       int start,
                                                       int len)

    - #### encodeUTF8

          public static java.nio.ByteBuffer encodeUTF8(java.nio.ByteBuffer buffer,
                                                       int bytesLength,
                                                       char[] text,
                                                       int start,
                                                       int len)

    - #### getDefaultSSLContext

          public static javax.net.ssl.SSLContext getDefaultSSLContext()

    - #### createDefaultSSLSocket

          public static java.net.Socket createDefaultSSLSocket(java.net.InetSocketAddress address)
                                                        throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### createDefaultSSLSocket

          public static java.net.Socket createDefaultSSLSocket(java.net.InetAddress host,
                                                               int port)
                                                        throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url,
                                                         java.util.Map<java.lang.String,java.lang.String> headers,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url,
                                                         java.util.Map<java.lang.String,java.lang.String> headers,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url,
                                                         java.nio.charset.Charset charset)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url,
                                                         java.nio.charset.Charset charset,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(java.lang.String url,
                                                         java.nio.charset.Charset charset,
                                                         java.util.Map<java.lang.String,java.lang.String> headers,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url,
                                                         java.nio.charset.Charset charset)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url,
                                                         java.nio.charset.Charset charset,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpContent

          public static java.lang.String postHttpContent(javax.net.ssl.SSLContext ctx,
                                                         java.lang.String url,
                                                         java.nio.charset.Charset charset,
                                                         java.util.Map<java.lang.String,java.lang.String> headers,
                                                         java.lang.String body)
                                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpBytesContent

          public static byte[] postHttpBytesContent(java.lang.String url)
                                             throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpBytesContent

          public static byte[] postHttpBytesContent(javax.net.ssl.SSLContext ctx,
                                                    java.lang.String url)
                                             throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpBytesContent

          public static byte[] postHttpBytesContent(java.lang.String url,
                                                    java.util.Map<java.lang.String,java.lang.String> headers,
                                                    java.lang.String body)
                                             throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### postHttpBytesContent

          public static byte[] postHttpBytesContent(javax.net.ssl.SSLContext ctx,
                                                    java.lang.String url,
                                                    java.util.Map<java.lang.String,java.lang.String> headers,
                                                    java.lang.String body)
                                             throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(java.lang.String url)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(javax.net.ssl.SSLContext ctx,
                                                        java.lang.String url)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(javax.net.ssl.SSLContext ctx,
                                                        java.lang.String url,
                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                        java.lang.String body)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(java.lang.String url,
                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                        java.lang.String body)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(java.lang.String url,
                                                        java.nio.charset.Charset charset)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(javax.net.ssl.SSLContext ctx,
                                                        java.lang.String url,
                                                        java.nio.charset.Charset charset)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(javax.net.ssl.SSLContext ctx,
                                                        java.lang.String url,
                                                        java.nio.charset.Charset charset,
                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                        java.lang.String body)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpContent

          public static java.lang.String getHttpContent(java.lang.String url,
                                                        java.nio.charset.Charset charset,
                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                        java.lang.String body)
                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpBytesContent

          public static byte[] getHttpBytesContent(java.lang.String url)
                                            throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpBytesContent

          public static byte[] getHttpBytesContent(javax.net.ssl.SSLContext ctx,
                                                   java.lang.String url)
                                            throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpBytesContent

          public static byte[] getHttpBytesContent(java.lang.String url,
                                                   java.util.Map<java.lang.String,java.lang.String> headers,
                                                   java.lang.String body)
                                            throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### getHttpBytesContent

          public static byte[] getHttpBytesContent(javax.net.ssl.SSLContext ctx,
                                                   java.lang.String url,
                                                   java.util.Map<java.lang.String,java.lang.String> headers,
                                                   java.lang.String body)
                                            throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### remoteHttpContent

          public static java.io.ByteArrayOutputStream remoteHttpContent(java.lang.String method,
                                                                        java.lang.String url,
                                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                                        java.lang.String body)
                                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### remoteHttpContent

          public static java.io.ByteArrayOutputStream remoteHttpContent(javax.net.ssl.SSLContext ctx,
                                                                        java.lang.String method,
                                                                        java.lang.String url,
                                                                        java.util.Map<java.lang.String,java.lang.String> headers,
                                                                        java.lang.String body)
                                                                 throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### read

          public static java.lang.String read(java.io.InputStream in)
                                       throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### read

          public static java.lang.String read(java.io.InputStream in,
                                              java.lang.String charsetName)
                                       throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### readStream

          public static java.io.ByteArrayOutputStream readStream(java.io.InputStream in)
                                                          throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### readBytes

          public static byte[] readBytes(java.io.InputStream in)
                                  throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### readStreamThenClose

          public static java.io.ByteArrayOutputStream readStreamThenClose(java.io.InputStream in)
                                                                   throws java.io.IOException

      抛出:
        `java.io.IOException`

    - #### readBytesThenClose

          public static byte[] readBytesThenClose(java.io.InputStream in)
                                           throws java.io.IOException

      抛出:
        `java.io.IOException`