change split

This commit is contained in:
Looly 2021-03-31 08:26:22 +08:00
parent ad54b670f9
commit c978dcc73b
2 changed files with 5 additions and 3 deletions

View File

@ -3,10 +3,11 @@
-------------------------------------------------------------------------------------------------------------
# 5.6.3 (2021-03-30)
# 5.6.3 (2021-03-31)
### 新特性
* 【core 】 修改数字转换的实现增加按照指定端序转换pr#1492@Github
* 【core 】 修改拆分byte数组时最后一组长度的规则pr#1494@Github
### Bug修复
-------------------------------------------------------------------------------------------------------------

View File

@ -528,14 +528,15 @@ public class PrimitiveArrayUtil {
*/
public static byte[][] split(byte[] array, int len) {
int amount = array.length / len;
int remainder = array.length % len;
final int remainder = array.length % len;
if (remainder != 0) {
++amount;
}
byte[][] arrays = new byte[amount][];
final byte[][] arrays = new byte[amount][];
byte[] arr;
for (int i = 0; i < amount; i++) {
if (i == amount - 1 && remainder != 0) {
// 有剩余按照实际长度创建
arr = new byte[remainder];
System.arraycopy(array, i * len, arr, 0, remainder);
} else {