This commit is contained in:
Looly
2023-04-26 19:43:51 +08:00
parent c2d419ffdc
commit ba2813becb
6 changed files with 342 additions and 109 deletions

View File

@@ -12,6 +12,7 @@
package org.dromara.hutool.core.util;
import org.dromara.hutool.core.io.buffer.FastByteBuffer;
import org.dromara.hutool.core.math.NumberUtil;
import java.math.BigDecimal;
@@ -608,4 +609,24 @@ public class ByteUtil {
}
return new BigInteger(1, mag);
}
/**
* 连接多个byte[]
*
* @param byteArrays 多个byte[]
* @return 连接后的byte[]
* @since 6.0.0
*/
public static byte[] concat(final byte[]... byteArrays){
int totalLength = 0;
for (final byte[] byteArray : byteArrays) {
totalLength += byteArray.length;
}
final FastByteBuffer buffer = new FastByteBuffer(totalLength);
for (final byte[] byteArray : byteArrays) {
buffer.append(byteArray);
}
return buffer.toArrayZeroCopyIfPossible();
}
}