Here you can find the source of getWriter(String fileName, Charset cs)
public static Writer getWriter(String fileName, Charset cs)
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; public class Main { public static final Charset defaultCharset = Charset.forName("UTF-8"); public static Writer getWriter(String fileName, Charset cs) { OutputStreamWriter writer = null; try {//from w w w . j a va2 s . c om return new OutputStreamWriter(new FileOutputStream(fileName), cs); } catch (FileNotFoundException e) { e.printStackTrace(); } return writer; } public static Writer getWriter(String fileName) { return getWriter(fileName, defaultCharset); } }