public static OutputStream toOutputStream ( final String s , final OutputStream os ) throws IOException { // This needs to be fast. final int length = s . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { assert s . charAt ( i ) < ( char ) 0x100 : s . charAt ( i ) ; os . write ( s . charAt ( i ) ) ; } return os ; }
Writes a string to an output stream discarding higher order bits .