Here you can find the source of writeStringToFile(File f, String s)
public static boolean writeStringToFile(File f, String s)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { public static final String charset = "UTF-8"; public static boolean writeStringToFile(File f, String s) { OutputStream out = null;//w w w . j a va 2 s. c o m try { out = new FileOutputStream(f); out.write(s.getBytes(charset)); return true; } catch (IOException e) { e.printStackTrace(); } finally { if (out != null) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } }