Here you can find the source of utf8Writer(final File f)
Parameter | Description |
---|---|
f | file to write to |
Parameter | Description |
---|---|
IOException | if the file couldn't be opened for writing |
public static Writer utf8Writer(final File f) 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.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { /** UTF-8 charset instance. */ public static final Charset UTF8 = Charset.forName("UTF-8"); /**/* ww w .j a va2 s . c o m*/ * Creates a {@link Writer} that writes to the given file, converting chars * to bytes using the UTF-8 charset. * * @param f * file to write to * @return Writer for the given file * @throws IOException * if the file couldn't be opened for writing */ public static Writer utf8Writer(final File f) throws IOException { return new OutputStreamWriter(new FileOutputStream(f), UTF8); } }