Java Array Clone cloneArray(byte[] bytes)

Here you can find the source of cloneArray(byte[] bytes)

Description

Returns null if given null, or clones into a new array only if not empty.

License

Apache License

Declaration

static byte[] cloneArray(byte[] bytes) 

Method Source Code

//package com.java2s;
/*//w w  w. ja  v a 2s .c  o m
 *  Copyright 2011-2015 Cojen.org
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

public class Main {
    /**
     * Returns null if given null, or clones into a new array only if not empty.
     */
    static byte[] cloneArray(byte[] bytes) {
        return (bytes == null || bytes.length == 0) ? bytes : bytes.clone();
    }
}

Related

  1. clone2dArray(double[][] myArray)
  2. clone2DArray(final boolean[][] array)
  3. clone_multidim_array(float[][] arr)
  4. cloneAndMultiplyArray(float[] array, float factor)
  5. cloneArray(boolean[][] src)
  6. cloneArray(byte[] in)
  7. cloneArray(double[][] a)
  8. cloneArray(Double[][] src)
  9. cloneArray(final String[] inputArray)