question: public static byte [ ] str2UnicodeByteArray ( final JBBPByteOrder byteOrder , final String str ) { final byte [ ] result = new byte [ str . length ( ) << 1 ] ; int index = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { final int val = str . charAt ( i ) ; switch ( byteOrder ) { case BIG_ENDIAN : { result [ index ++ ] = ( byte ) ( val > > 8 ) ; result [ index ++ ] = ( byte ) val ; } break ; case LITTLE_ENDIAN : { result [ index ++ ] = ( byte ) val ; result [ index ++ ] = ( byte ) ( val > > 8 ) ; } break ; default : throw new Error ( "Unexpected byte order [" + byteOrder + ']' ) ; } } return result ; }
target:  Convert chars of a string into a byte array contains the unicode codes.