/** * Creates a buffered writer in the default encoding * * @param filename the name or path of the file * @param append whether to append to the files if it exists */ public static BufferedWriter createWriter(String filename, boolean append) throws IOException { createDirectory(filename); return new BufferedWriter(new FileWriter(filename, append)); }
/** * Creates a buffered writer in the default encoding * * @param file the file to write to * @param append whether to append to the files if it exists */ public static BufferedWriter createWriter(File file, boolean append) throws IOException { createDirectory(file.getAbsolutePath()); return new BufferedWriter(new FileWriter(file, append)); }
/** * Creates a buffered writer, * and the directories to contain it if they do not exist * * @param filename the name or path of the file * @param encoding the encoding to use, for instance "UTF-8" * @param append whether to append to the files if it exists */ public static BufferedWriter createWriter(String filename, String encoding, boolean append) throws IOException { createDirectory(filename); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename, append), encoding)); }
/** * Creates a buffered writer, * and the directories to contain it if they do not exist * * @param file the file to write to * @param encoding the encoding to use, for instance "UTF-8" * @param append whether to append to the files if it exists */ public static BufferedWriter createWriter(File file, String encoding, boolean append) throws IOException { createDirectory(file.getAbsolutePath()); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, append),encoding)); }