Here you can find the source of newWriter(File file, Charset charset)
static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException
//package com.java2s; //License from project: Apache License 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; import javax.annotation.Nullable; public class Main { static BufferedWriter newWriter(File file, Charset charset) throws FileNotFoundException { checkNotNull(file);//from w ww .jav a2 s . c o m checkNotNull(charset); return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); } static <T> T checkNotNull(T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } return reference; } static <T> T checkNotNull(T reference) { if (reference == null) { throw new NullPointerException(); } return reference; } }