Java Byte Array Copy copyBytes(byte[] src, int start, int end)

Here you can find the source of copyBytes(byte[] src, int start, int end)

Description

Copy bytes from src to dest, if they are available in src

License

Open Source License

Parameter

Parameter Description
src a parameter
start a parameter
end a parameter

Declaration

public static byte[] copyBytes(byte[] src, int start, int end) 

Method Source Code

//package com.java2s;
/**//  w w  w .  ja v  a 2s  .c  o m
 * Confidential Information.
 * Copyright (C) 2007-2009 Eric Link, All rights reserved.
 * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 **/

public class Main {
    /**
     * Copy bytes from src to dest, if they are available in src
     * @param src
     * @param start
     * @param end
     * @return
     */
    public static byte[] copyBytes(byte[] src, int start, int end) {
        int length = end - start;
        byte[] dest = new byte[length];

        for (int i = 0; i < length && i < src.length; i++) {
            dest[i] = src[i - start];
        }

        return dest;
    }
}

Related

  1. copyBytes(byte[] from, int offset, int len)
  2. copyBytes(byte[] results, int offset, int int32)
  3. copyBytes(byte[] source, byte[] dest, int sourceFrom, int copyLength, int destFrom)
  4. copyBytes(byte[] src)
  5. copyBytes(byte[] src, byte[] target)
  6. copyBytes(final byte[] source, final int sOffset, final byte[] destination, final int dOffset, final int length)
  7. copyBytes(int[] srcArray, int srcPos, byte[] destBytes)
  8. copyBytes(long sourceOffset, byte[] source, int sourceOff, int sourceLength, long destOffset, byte[] dest, int destLength)
  9. copyBytesAtOffset(byte[] dst, byte[] src, int offset)