public static void writeStringToStream(String string,OutputStream stream,Charset charset) throws IOException {
  OutputStreamWriter osw=new OutputStreamWriter(stream,charset);
  try {
    osw.append(string);
    osw.flush();
  }
  finally {
    osw.close();
  }
}

public static void writeStringToStream ( String string , OutputStream stream , Charset charset ) throws IOException { OutputStreamWriter osw = new OutputStreamWriter ( stream , charset ) ; try { osw . append ( string ) ; osw . flush ( ) ; } finally { osw . close ( ) ; } }
writes given string to given stream , using given charset
