public static byte [ ] toRawByteArray ( final char [ ] carr ) { byte [ ] barr = new byte [ carr . length << 1 ] ; for ( int i = 0 , bpos = 0 ; i < carr . length ; i ++ ) { char c = carr [ i ] ; barr [ bpos ++ ] = ( byte ) ( ( c & 0xFF00 ) >> 8 ) ; barr [ bpos ++ ] = ( byte ) ( c & 0x00FF ) ; } return barr ; }
Converts char array into byte array by replacing each character with two bytes .