Java Byte Array Value Set setBytes(final byte[] dest, final byte[] data, final int offset, int length)

Here you can find the source of setBytes(final byte[] dest, final byte[] data, final int offset, int length)

Description

add a bunch of bytes to the byte array with offset

License

Open Source License

Parameter

Parameter Description
dest bytes array which will contain the given bytes after the call
data a bunch of bytes to be added to the array
offset from where the data to be add to the dest
length length of the bytes to be add

Declaration

public static void setBytes(final byte[] dest, final byte[] data, final int offset, int length) 

Method Source Code

//package com.java2s;
/**/*  w  w w.  j a  v a 2s. c  o  m*/
 *    Created on Oct 21, 2010
 *    This file is part of JObexFTP 2.0, and it contains parts of OBEX4J.
 *
 *    JObexFTP 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.
 *
 *    JObexFTP 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 Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with JObexFTP.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

public class Main {
    /**
     * add a bunch of bytes to the byte array with offset
     *
     * @param dest bytes array which will contain the given bytes after the call
     * @param data a bunch of bytes to be added to the array
     * @param offset from where the data to be add to the dest
     * @param length length of the bytes to be add
     */
    public static void setBytes(final byte[] dest, final byte[] data, final int offset, int length) {
        if (offset + length > dest.length) {
            return;
        }
        for (int i = 0; i < length; i++) {
            dest[offset + i] = data[i];
        }
    }
}

Related

  1. setByte(byte[] buffer, int index, int val)
  2. setByte(byte[] byteArray, int offset, byte b)
  3. setbytes(byte dest[], int offset, byte src[])
  4. setBytes(byte[] destination, int offset, byte[] source)
  5. setBytes(byte[] setTo, int startTo, byte[] setFrom, int startFrom, int len)
  6. setBytes(int value, int offset, byte[] bytes)
  7. setBytes(long value, int offset, byte[] bytes)
  8. setBytes(short value, int offset, byte[] bytes)
  9. setBytesFromInt(byte[] ret, int value, int offs)