Here you can find the source of setText(File file, String text)
public static void setText(File file, String text) throws Exception
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2011 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ import java.io.*; public class Main { public static void setText(File file, String text) throws Exception { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); bw.write(text, 0, text.length()); bw.flush();//from w w w . jav a 2 s . c o m bw.close(); } }