Here you can find the source of getUTF8FileWriter(File f)
public static Writer getUTF8FileWriter(File f) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**//from w ww .j a v a 2 s .com * current working directory. Can be changed if needed */ private static String cwd = "."; public static Writer getUTF8FileWriter(File f) throws FileNotFoundException { return getUTF8FileWriter(f.getPath()); } public static Writer getUTF8FileWriter(String filename) throws FileNotFoundException { return new BufferedWriter( new OutputStreamWriter(new FileOutputStream(getFile(filename)), StandardCharsets.UTF_8)); } public static Path getPath(String path) { Path p = Paths.get(path); if (p.isAbsolute()) return p; else // making this absolute protects against the CWD being added twice return Paths.get(cwd, path).toAbsolutePath(); } public static File getFile(String path) { return getPath(path).toFile(); } }