com.hibegin.common.util.BytesUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simplewebserver Show documentation
Show all versions of simplewebserver Show documentation
Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project.
Can quickly run embedded, Android devices
package com.hibegin.common.util;
/**
* 字节,字节数组(合并,截取)
*/
public class BytesUtil {
public static byte[] mergeBytes(byte[]... bytes) {
int bytesSize = 0;
for (byte[] bs : bytes) {
bytesSize += bs.length;
}
byte[] nBytes = new byte[bytesSize];
int size = 0;
for (byte[] bs : bytes) {
System.arraycopy(bs, 0, nBytes, size, bs.length);
size += bs.length;
}
return nBytes;
}
public static byte[] subBytes(byte[] b, int start, int length) {
int nLength = Math.min(b.length, length);
byte[] bytes = new byte[nLength];
System.arraycopy(b, start, bytes, 0, nLength);
return bytes;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy