Here you can find the source of getBufferedUTF8Writer(File file)
Parameter | Description |
---|---|
file | File in UTF-8 encoding |
Parameter | Description |
---|---|
FileNotFoundException | an exception |
public static BufferedWriter getBufferedUTF8Writer(File file) throws FileNotFoundException
//package com.java2s; /** /*from w w w .j av a2 s . c o m*/ This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga) Some utility methods for arrays */ import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; public class Main { /** * Creates a BufferedWriter for UTF-8-encoded files * * @param file File in UTF-8 encoding * @return BufferedWriter for file * @throws FileNotFoundException */ public static BufferedWriter getBufferedUTF8Writer(File file) throws FileNotFoundException { return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8"))); } /** * Creates a BufferedWriter for UTF-8-encoded files * * @param fileName Path to file in UTF-8 encoding * @return BufferedWriter for file * @throws FileNotFoundException */ public static BufferedWriter getBufferedUTF8Writer(String fileName) throws FileNotFoundException { return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName), Charset.forName("UTF-8"))); } }