public PrintWriter createTextFile(Location loc,
                                      String pkg,
                                      File relPath,
                                      String charsetName) throws IOException {
        File file = (pkg.length() == 0)
                        ? relPath
                        : new File(nameToPath(pkg), relPath.getPath());
        if (charsetName == null) {
            charsetName = encoding;
        }
        return getPrintWriter(loc, file.getPath(), charsetName, null, FileKind.OTHER);
    }