Here you can find the source of utf8Writer(File file)
Parameter | Description |
---|---|
file | the file to write to |
Parameter | Description |
---|---|
FileNotFoundException | if the file cannot be written to |
public static Writer utf8Writer(File file) throws FileNotFoundException
//package com.java2s; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { private static final Charset UTF8 = Charset.forName("UTF-8"); /**/*ww w. ja v a 2s.c om*/ * Creates a writer whose character encoding is set to "UTF-8". * @param out the output stream to write to * @return the writer */ public static Writer utf8Writer(OutputStream out) { return new OutputStreamWriter(out, UTF8); } /** * Creates a writer whose character encoding is set to "UTF-8". * @param file the file to write to * @return the writer * @throws FileNotFoundException if the file cannot be written to */ public static Writer utf8Writer(File file) throws FileNotFoundException { return utf8Writer(file, false); } /** * Creates a writer whose character encoding is set to "UTF-8". * @param file the file to write to * @param append true to append to the end of the file, false to overwrite * it * @return the writer * @throws FileNotFoundException if the file cannot be written to */ public static Writer utf8Writer(File file, boolean append) throws FileNotFoundException { return utf8Writer(new FileOutputStream(file, append)); } }