This commit is contained in:
liulu
2024-12-05 16:49:32 +08:00
parent b87165b850
commit 0f61f4be5b
8 changed files with 318 additions and 26 deletions
@@ -10,6 +10,20 @@ import java.util.Arrays;
*/
public abstract class LangUtils {
public static byte[] removeLastZero(byte[] bytes) {
if (bytes == null) {
return bytes;
}
int len = bytes.length;
for (int i = len - 1; i >= 0; i--) {
if (bytes[i] != 0) {
return Arrays.copyOfRange(bytes, 0, i + 1);
}
}
return bytes;
}
public static byte[] merge(byte[]... bytes) {
int newLen = Arrays.stream(bytes).mapToInt(it -> it.length).sum();
byte[] res = new byte[newLen];