Here you can find the source of getPrintwriter(File file, boolean append)
Parameter | Description |
---|---|
file | - file to write into |
append | - append or overwrite file content |
public static PrintWriter getPrintwriter(File file, boolean append) throws IOException
//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; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.zip.GZIPOutputStream; public class Main { /**/*from w w w .j a va2s . c om*/ * Return print writer for file with UTF8 encoding. * <p> * If filename ends with .gz - file will be compressed * * @param file - file to write into * @param append - append or overwrite file content * */ public static PrintWriter getPrintwriter(File file, boolean append) throws IOException { OutputStream os = new FileOutputStream(file, append); if (file.getName().endsWith(".gz")) { os = new GZIPOutputStream(os); } return new PrintWriter(new OutputStreamWriter(os, "UTF8")); } }