Package org.aoju.bus.core.io
Class ByteString
java.lang.Object
org.aoju.bus.core.io.ByteString
- All Implemented Interfaces:
Serializable,Comparable<ByteString>
- Direct Known Subclasses:
ByteBuffer
不可变的字节序列
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbase64()intcompareTo(ByteString byteString) static ByteStringdecodeBase64(String base64) static ByteStringstatic ByteStringencodeString(String s, Charset charset) static ByteStringencodeUtf8(String s) final booleanendsWith(byte[] suffix) final booleanendsWith(ByteString suffix) booleanbytegetByte(int pos) inthashCode()hex()hmacSha1(ByteString key) hmacSha256(ByteString key) hmacSha512(ByteString key) final intindexOf(byte[] other) intindexOf(byte[] other, int fromIndex) final intindexOf(ByteString other) final intindexOf(ByteString other, int fromIndex) byte[]final intlastIndexOf(byte[] other) intlastIndexOf(byte[] other, int fromIndex) final intlastIndexOf(ByteString other) final intlastIndexOf(ByteString other, int fromIndex) md5()static ByteStringof(byte... data) static ByteStringof(byte[] data, int offset, int byteCount) static ByteStringof(ByteBuffer data) booleanrangeEquals(int offset, byte[] other, int otherOffset, int byteCount) booleanrangeEquals(int offset, ByteString other, int otherOffset, int byteCount) static ByteStringread(InputStream in, int byteCount) sha1()sha256()sha512()intsize()final booleanstartsWith(byte[] prefix) final booleanstartsWith(ByteString prefix) substring(int beginIndex) substring(int beginIndex, int endIndex) byte[]utf8()voidwrite(OutputStream out) void
-
Field Details
-
EMPTY
-
hashCode
public transient int hashCode
-
-
Constructor Details
-
ByteString
public ByteString() -
ByteString
public ByteString(byte[] data)
-
-
Method Details
-
of
-
of
-
of
-
encodeUtf8
-
encodeString
-
decodeBase64
-
decodeHex
-
read
- Throws:
IOException
-
utf8
-
string
-
base64
-
md5
-
sha1
-
sha256
-
sha512
-
hmacSha1
-
hmacSha256
-
hmacSha512
-
base64Url
-
hex
-
toAsciiLowercase
-
toAsciiUppercase
-
substring
-
substring
-
getByte
public byte getByte(int pos) -
size
public int size() -
toByteArray
public byte[] toByteArray() -
internalArray
public byte[] internalArray() -
asByteBuffer
-
write
- Throws:
IOException
-
write
-
rangeEquals
-
rangeEquals
public boolean rangeEquals(int offset, byte[] other, int otherOffset, int byteCount) -
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
- Specified by:
compareToin interfaceComparable<ByteString>
-