Java Array Sub Array subarray(byte[] src, int beginIndex)

Here you can find the source of subarray(byte[] src, int beginIndex)

Description

subarray

License

Open Source License

Declaration

public static byte[] subarray(byte[] src, int beginIndex) 

Method Source Code

//package com.java2s;
/*/*from  w ww.  ja v a  2  s.  com*/
* Copyright (c) 2000 - 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/

public class Main {
    public static byte[] subarray(byte[] src, int beginIndex) {
        if (beginIndex == 0) {
            return src;
        }
        byte[] res = new byte[src.length - beginIndex];
        System.arraycopy(src, beginIndex, res, 0, res.length);
        return res;
    }

    public static byte[] subarray(byte[] src, int beginIndex, int endIndex) {
        if (beginIndex == 0 && endIndex == src.length) {
            return src;
        }
        if (endIndex > src.length) {
            endIndex = src.length;
        }

        byte[] res = new byte[endIndex - beginIndex];
        System.arraycopy(src, beginIndex, res, 0, res.length);
        return res;
    }
}

Related

  1. subarray(byte[] in, int a, int b)
  2. subarray(byte[] in, int arg1, int arg2)
  3. subArray(byte[] in, int start, int end)
  4. subArray(byte[] input, int start)
  5. subArray(byte[] source, int start, int len)
  6. subArray(byte[] src, int offset, int len)
  7. subArray(byte[] src, int pos, int length)
  8. subArray(byte[] src, int start)
  9. subArray(byte[] src, int start, int limit)