Here you can find the source of writeString(String content, String path, String charset)
public static void writeString(String content, String path, String charset) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static void writeString(String content, String path, String charset) throws IOException { PrintWriter writer = null; try {// w w w .j a v a 2 s . c o m writer = getPrintWriter(path, charset, false); writer.print(content); } finally { close(writer); } } public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IOException { return new PrintWriter(getBufferedWriter(path, charset, isAppend)); } public static void close(Closeable closeable) { if (closeable == null) return; try { closeable.close(); } catch (IOException ignored) { } } public static BufferedWriter getBufferedWriter(String path, String charset, boolean isAppend) throws IOException { return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch(path), isAppend), charset)); } public static File touch(String fullFilePath) throws IOException { if (fullFilePath == null) { return null; } File file = new File(fullFilePath); file.getParentFile().mkdirs(); if (!file.exists()) file.createNewFile(); return file; } }