mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
change split
This commit is contained in:
parent
ad54b670f9
commit
c978dcc73b
@ -3,10 +3,11 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.6.3 (2021-03-30)
|
# 5.6.3 (2021-03-31)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【core 】 修改数字转换的实现,增加按照指定端序转换(pr#1492@Github)
|
* 【core 】 修改数字转换的实现,增加按照指定端序转换(pr#1492@Github)
|
||||||
|
* 【core 】 修改拆分byte数组时最后一组长度的规则(pr#1494@Github)
|
||||||
### Bug修复
|
### Bug修复
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -528,14 +528,15 @@ public class PrimitiveArrayUtil {
|
|||||||
*/
|
*/
|
||||||
public static byte[][] split(byte[] array, int len) {
|
public static byte[][] split(byte[] array, int len) {
|
||||||
int amount = array.length / len;
|
int amount = array.length / len;
|
||||||
int remainder = array.length % len;
|
final int remainder = array.length % len;
|
||||||
if (remainder != 0) {
|
if (remainder != 0) {
|
||||||
++amount;
|
++amount;
|
||||||
}
|
}
|
||||||
byte[][] arrays = new byte[amount][];
|
final byte[][] arrays = new byte[amount][];
|
||||||
byte[] arr;
|
byte[] arr;
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
if (i == amount - 1 && remainder != 0) {
|
if (i == amount - 1 && remainder != 0) {
|
||||||
|
// 有剩余,按照实际长度创建
|
||||||
arr = new byte[remainder];
|
arr = new byte[remainder];
|
||||||
System.arraycopy(array, i * len, arr, 0, remainder);
|
System.arraycopy(array, i * len, arr, 0, remainder);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user