Here you can find the source of getPrintWriter(String path, String charset, boolean isAppend)
public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IOException { return new PrintWriter(getBufferedWriter(path, charset, isAppend)); }/*from ww w. j av a2 s .co m*/ 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; } }