Here you can find the source of flatten2DArray(byte[][] array)
Parameter | Description |
---|---|
array | The uniform 2D array to flatten |
public static byte[] flatten2DArray(byte[][] array)
//package com.java2s; /*/*from w w w . jav a 2 s. co m*/ * Copyright (c) 2010 Matthew J. Francis and Contributors of the Bobbin Project * This file is distributed under the MIT licence. See the LICENCE file for further information. */ public class Main { /** * Flattens a uniform 2D array into a 1D array * * @param array The uniform 2D array to flatten * @return The flattened 1D array */ public static byte[] flatten2DArray(byte[][] array) { byte[] flattenedArray = new byte[array.length * array[0].length]; for (int i = 0; i < array.length; i++) { System.arraycopy(array[i], 0, flattenedArray, i * array[0].length, array[0].length); } return flattenedArray; } }