Here you can find the source of writeString(String path, String str)
public static void writeString(String path, String str)
//package com.java2s; //License from project: Open Source License import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void writeString(String path, String str) { BufferedWriter out = null; try {//from w ww .j av a 2s. c o m File f = new File(path); File parent = f.getParentFile(); if (!parent.exists()) parent.mkdirs(); out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), "utf-8")); out.write(str); } catch (IOException ex) { throw new RuntimeException(ex); } finally { if (out != null) { try { out.close(); } catch (Exception ex) { } } } } }