集册 Java实例教程 连接两个字节数组。

连接两个字节数组。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

387
连接两个字节数组。

/* 
*来 自
 nowjava - 时代Java
*/

import java.io.IOException;

import java.io.InputStream;

import java.nio.ByteBuffer;

import java.util.Iterator;

import org.apache.log4j.Logger;


public class Main{

    public static void main(String[] argv) throws Exception{

        byte[] a1 = new byte[]{34,35,36,37,37,37,67,68,69};

        byte[] a2 = new byte[]{34,35,36,37,37,37,67,68,69};

        System.out.println(java.util.Arrays.toString(concat(a1,a2)));

    }

    /**

     * Concatenates two byte arrays.

     * @param a1

     * @param a2

     * @return concatenated array. the returned array has length = a1.length+a2.length

     */

    final static public byte[] concat(byte[] a1, byte[] a2) {

        byte[] ret = 
展开阅读全文