Here you can find the source of join(byte[]... bs)
Parameter | Description |
---|---|
bs | the bs |
public static byte[] join(byte[]... bs)
//package com.java2s; /**/*from ww w .j av a 2 s . co m*/ * This file is part of the Nilestore project. * * Copyright (C) (2011) Nile University (NU) * * Nilestore is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * 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 General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.util.List; public class Main { /** * Join. * * @param bs * the bs * @return the byte[] */ public static byte[] join(byte[]... bs) { int len = 0; for (byte[] b : bs) { len += b.length; } byte[] out = new byte[len]; int offset = 0; for (byte[] b : bs) { System.arraycopy(b, 0, out, offset, b.length); offset += b.length; } return out; } /** * Join. * * @param bs * the bs * @return the byte[] */ public static byte[] join(List<byte[]> bs) { int len = 0; for (byte[] b : bs) { len += b.length; } byte[] out = new byte[len]; int offset = 0; for (byte[] b : bs) { System.arraycopy(b, 0, out, offset, b.length); offset += b.length; } return out; } }