public static < T > T [ ] concatAll ( final T [ ] empty , Iterable < T [ ] > arrayList ) { assert ( empty . length == 0 ) ; if ( arrayList . iterator ( ) . hasNext ( ) == false ) { return empty ; } int len = 0 ; for ( T [ ] subArray : arrayList ) { len += subArray . length ; } int pos = 0 ; T [ ] result = Arrays . copyOf ( empty , len ) ; for ( T [ ] subArray : arrayList ) { System . arraycopy ( subArray , 0 , result , pos , subArray . length ) ; pos += subArray . length ; } return result ; }
Concatenate an list of arrays of typed - objects