All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hibegin.common.util.BytesUtil Maven / Gradle / Ivy

Go to download

Simple, flexible, less dependent, more extended. Less memory footprint, can quickly build Web project. Can quickly run embedded, Android devices

There is a newer version: 0.3.162
Show newest version
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