public static void write ( File file , String text , String charset ) throws IOException { Writer writer = null ; try { FileOutputStream out = new FileOutputStream ( file ) ; writeUTF16BomIfRequired ( charset , out ) ; writer = new OutputStreamWriter ( out , charset ) ; writer . write ( text ) ; writer . flush ( ) ; Writer temp = writer ; writer = null ; temp . close ( ) ; } finally { closeWithWarning ( writer ) ; } }
Write the text to the File using the specified encoding .