类 ByteString
java.lang.Object
com.lark.oapi.okio.ByteString
- 所有已实现的接口:
Serializable,Comparable<ByteString>
An immutable sequence of bytes.
Byte strings compare lexicographically as a sequence of unsigned bytes. That
is, the byte string ff sorts after 00. This is counter to the sort order of the
corresponding bytes, where -1 sorts before 0.
Full disclosure: this class provides untrusted input and output streams with raw access to the underlying byte array. A hostile stream implementation could keep a reference to the mutable byte string, violating the immutable guarantee of this class. For this reason a byte string's immutability guarantee cannot be relied upon for security in applets and other environments that run both trusted and untrusted code in the same process.
- 另请参阅:
-
字段概要
字段 -
方法概要
修饰符和类型方法说明Returns aByteBufferview of the bytes in thisByteString.base64()Returns this byte string encoded as Base64.Returns this byte string encoded as URL-safe Base64.intcompareTo(ByteString byteString) static ByteStringdecodeBase64(String base64) Decodes the Base64-encoded bytes and returns their value as a byte string.static ByteStringDecodes the hex-encoded bytes and returns their value a byte string.static ByteStringencodeString(String s, Charset charset) Returns a new byte string containing thecharset-encoded bytes ofs.static ByteStringencodeUtf8(String s) Returns a new byte string containing theUTF-8bytes ofs.final booleanendsWith(byte[] suffix) final booleanendsWith(ByteString suffix) booleanbytegetByte(int pos) Returns the byte atpos.inthashCode()hex()Returns this byte string encoded in hexadecimal.hmacSha1(ByteString key) Returns the 160-bit SHA-1 HMAC of this byte string.hmacSha256(ByteString key) Returns the 256-bit SHA-256 HMAC of this byte string.hmacSha512(ByteString key) Returns the 512-bit SHA-512 HMAC of this byte string.final intindexOf(byte[] other) intindexOf(byte[] other, int fromIndex) final intindexOf(ByteString other) final intindexOf(ByteString other, int fromIndex) final intlastIndexOf(byte[] other) intlastIndexOf(byte[] other, int fromIndex) final intlastIndexOf(ByteString other) final intlastIndexOf(ByteString other, int fromIndex) md5()Returns the 128-bit MD5 hash of this byte string.static ByteStringof(byte... data) Returns a new byte string containing a clone of the bytes ofdata.static ByteStringof(byte[] data, int offset, int byteCount) Returns a new byte string containing a copy ofbyteCountbytes ofdatastarting atoffset.static ByteStringof(ByteBuffer data) booleanrangeEquals(int offset, byte[] other, int otherOffset, int byteCount) Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount).booleanrangeEquals(int offset, ByteString other, int otherOffset, int byteCount) Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount).static ByteStringread(InputStream in, int byteCount) Readscountbytes frominand returns the result.sha1()Returns the 160-bit SHA-1 hash of this byte string.sha256()Returns the 256-bit SHA-256 hash of this byte string.sha512()Returns the 512-bit SHA-512 hash of this byte string.intsize()Returns the number of bytes in this ByteString.final booleanstartsWith(byte[] prefix) final booleanstartsWith(ByteString prefix) Constructs a newStringby decoding the bytes usingcharset.substring(int beginIndex) Returns a byte string that is a substring of this byte string, beginning at the specified index until the end of this string.substring(int beginIndex, int endIndex) Returns a byte string that is a substring of this byte string, beginning at the specifiedbeginIndexand ends at the specifiedendIndex.Returns a byte string equal to this byte string, but with the bytes 'A' through 'Z' replaced with the corresponding byte in 'a' through 'z'.Returns a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced with the corresponding byte in 'A' through 'Z'.byte[]Returns a byte array containing a copy of the bytes in thisByteString.toString()Returns a human-readable string that describes the contents of this byte string.utf8()Constructs a newStringby decoding the bytes asUTF-8.voidwrite(OutputStream out) Writes the contents of this byte string toout.
-
字段详细资料
-
EMPTY
A singleton emptyByteString.
-
-
方法详细资料
-
of
Returns a new byte string containing a clone of the bytes ofdata. -
of
Returns a new byte string containing a copy ofbyteCountbytes ofdatastarting atoffset. -
of
-
encodeUtf8
Returns a new byte string containing theUTF-8bytes ofs. -
encodeString
Returns a new byte string containing thecharset-encoded bytes ofs. -
decodeBase64
Decodes the Base64-encoded bytes and returns their value as a byte string. Returns null ifbase64is not a Base64-encoded sequence of bytes. -
decodeHex
Decodes the hex-encoded bytes and returns their value a byte string. -
read
Readscountbytes frominand returns the result.- 抛出:
EOFException- ifinhas fewer thancountbytes to read.IOException
-
utf8
Constructs a newStringby decoding the bytes asUTF-8. -
string
Constructs a newStringby decoding the bytes usingcharset. -
base64
Returns this byte string encoded as Base64. In violation of the RFC, the returned string does not wrap lines at 76 columns. -
md5
Returns the 128-bit MD5 hash of this byte string. -
sha1
Returns the 160-bit SHA-1 hash of this byte string. -
sha256
Returns the 256-bit SHA-256 hash of this byte string. -
sha512
Returns the 512-bit SHA-512 hash of this byte string. -
hmacSha1
Returns the 160-bit SHA-1 HMAC of this byte string. -
hmacSha256
Returns the 256-bit SHA-256 HMAC of this byte string. -
hmacSha512
Returns the 512-bit SHA-512 HMAC of this byte string. -
base64Url
Returns this byte string encoded as URL-safe Base64. -
hex
Returns this byte string encoded in hexadecimal. -
toAsciiLowercase
Returns a byte string equal to this byte string, but with the bytes 'A' through 'Z' replaced with the corresponding byte in 'a' through 'z'. Returns this byte string if it contains no bytes in 'A' through 'Z'. -
toAsciiUppercase
Returns a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced with the corresponding byte in 'A' through 'Z'. Returns this byte string if it contains no bytes in 'a' through 'z'. -
substring
Returns a byte string that is a substring of this byte string, beginning at the specified index until the end of this string. Returns this byte string ifbeginIndexis 0. -
substring
Returns a byte string that is a substring of this byte string, beginning at the specifiedbeginIndexand ends at the specifiedendIndex. Returns this byte string ifbeginIndexis 0 andendIndexis the length of this byte string. -
getByte
public byte getByte(int pos) Returns the byte atpos. -
size
public int size()Returns the number of bytes in this ByteString. -
toByteArray
public byte[] toByteArray()Returns a byte array containing a copy of the bytes in thisByteString. -
asByteBuffer
Returns aByteBufferview of the bytes in thisByteString. -
write
Writes the contents of this byte string toout.- 抛出:
IOException
-
rangeEquals
Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds. -
rangeEquals
public boolean rangeEquals(int offset, byte[] other, int otherOffset, int byteCount) Returns true if the bytes of this in[offset..offset+byteCount)equal the bytes ofotherin[otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds. -
startsWith
-
startsWith
public final boolean startsWith(byte[] prefix) -
endsWith
-
endsWith
public final boolean endsWith(byte[] suffix) -
indexOf
-
indexOf
-
indexOf
public final int indexOf(byte[] other) -
indexOf
public int indexOf(byte[] other, int fromIndex) -
lastIndexOf
-
lastIndexOf
-
lastIndexOf
public final int lastIndexOf(byte[] other) -
lastIndexOf
public int lastIndexOf(byte[] other, int fromIndex) -
equals
-
hashCode
public int hashCode() -
compareTo
- 指定者:
compareTo在接口中Comparable<ByteString>
-
toString
Returns a human-readable string that describes the contents of this byte string. Typically this is a string like[text=Hello]or[hex=0000ffff].
-