| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
allocateReuseBytes(int length)
Allocate bytes that is only for temporary usage, it should not be stored in somewhere else.
|
static char[] |
allocateReuseChars(int length) |
static String |
decodeUTF8(byte[] input,
int offset,
int byteLen) |
static int |
decodeUTF8Strict(byte[] sa,
int sp,
int len,
char[] da) |
static String |
defaultDecodeUTF8(byte[] bytes,
int offset,
int len) |
static int |
defaultEncodeUTF8(String str,
byte[] bytes) |
static byte[] |
encodeUTF8(String str)
This method must have the same result with JDK's String.getBytes.
|
static int |
encodeUTF8(String str,
byte[] bytes) |
public static byte[] encodeUTF8(String str)
public static int encodeUTF8(String str, byte[] bytes)
public static int defaultEncodeUTF8(String str, byte[] bytes)
public static String decodeUTF8(byte[] input, int offset, int byteLen)
public static int decodeUTF8Strict(byte[] sa,
int sp,
int len,
char[] da)
public static String defaultDecodeUTF8(byte[] bytes, int offset, int len)
public static byte[] allocateReuseBytes(int length)
ThreadLocal to reuse bytes to avoid overhead of byte[] new and gc.
If there are methods that can only accept a byte[], instead of a MemorySegment[] parameter, we can allocate a reuse bytes and copy the MemorySegment data to byte[], then call the method. Such as String deserialization.
public static char[] allocateReuseChars(int length)
Copyright © 2025 The Apache Software Foundation. All rights reserved.