public static void write ( String str , final OutputStream outputStream , Charset charset ) throws IOException { new ByteSink ( ) { @ Override public OutputStream openStream ( ) { return outputStream ; } } . asCharSink ( charset ) . write ( str ) ; }
Writes the specified string to stream with buffering and closes the stream .