Here you can find the source of appendArray(final byte[] buffer1, final byte[] buffer2)
Parameter | Description |
---|---|
buffer1 | The first buffer. |
buffer2 | The second buffer. |
public static final byte[] appendArray(final byte[] buffer1, final byte[] buffer2)
//package com.java2s; /**/*from ww w.j a v a 2s . c o m*/ * (C) Copyright 2007, Deft Labs. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Appends the second array to the first array. The buffer1 object * is modified to include the buffer2 object. * @param buffer1 The first buffer. * @param buffer2 The second buffer. * @return The new array. */ public static final byte[] appendArray(final byte[] buffer1, final byte[] buffer2) { final byte[] newBuffer = new byte[buffer1.length + buffer2.length]; int pos = 0; System.arraycopy(buffer1, 0, newBuffer, pos, buffer1.length); pos += buffer1.length; System.arraycopy(buffer2, 0, newBuffer, pos, buffer2.length); return newBuffer; } }