public static UTF8String concat ( UTF8String ... inputs ) { // Compute the total length of the result. long totalLength = 0 ; for ( int i = 0 ; i < inputs . length ; i ++ ) { if ( inputs [ i ] != null ) { totalLength += ( long ) inputs [ i ] . numBytes ; } else { return null ; } } // Allocate a new byte array, and copy the inputs one by one into it. final byte [ ] result = new byte [ Ints . checkedCast ( totalLength ) ] ; int offset = 0 ; for ( int i = 0 ; i < inputs . length ; i ++ ) { int len = inputs [ i ] . numBytes ; copyMemory ( inputs [ i ] . base , inputs [ i ] . offset , result , BYTE_ARRAY_OFFSET + offset , len ) ; offset += len ; } return fromBytes ( result ) ; }
Concatenates input strings together into a single string . Returns null if any input is null .