Here you can find the source of writeString(File file, String string)
public static void writeString(File file, String string) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void writeString(File file, String string) throws IOException { writeString(file, string, "UTF-8"); }/*from w ww .ja va 2 s . c o m*/ public static void writeString(File file, String string, String encode) { OutputStreamWriter write = null; BufferedWriter writer = null; try { write = new OutputStreamWriter(new FileOutputStream(file), encode); writer = new BufferedWriter(write); writer.write(string); writer.close(); } catch (Exception e) { throw new RuntimeException("writeString to file " + file.getPath(), e); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { } } if (write != null) { try { write.close(); } catch (IOException e) { } } } } }