Here you can find the source of getReader(String fileName, Charset cs)
public static Reader getReader(String fileName, Charset cs)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.nio.charset.Charset; public class Main { public static final Charset defaultCharset = Charset.forName("UTF-8"); public static Reader getReader(String fileName, Charset cs) { Reader reader = null;//from w ww . ja v a 2 s . c om try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), cs)); } catch (FileNotFoundException e) { e.printStackTrace(); } return reader; } public static Reader getReader(String fileName) { return getReader(fileName, defaultCharset); } public static Reader getReader(File file, Charset cs) { Reader reader = null; try { reader = getReader(new FileInputStream(file), cs); } catch (FileNotFoundException e) { e.printStackTrace(); } return reader; } public static Reader getReader(File file) { return getReader(file, defaultCharset); } public static Reader getReader(URL url, Charset cs) { Reader reader = null; try { reader = getReader(url.openStream(), cs); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return reader; } public static Reader getReader(URL url) { return getReader(url, defaultCharset); } public static Reader getReader(InputStream inStream, Charset cs) { Reader reader = null; reader = new BufferedReader(new InputStreamReader(inStream, cs)); return reader; } public static Reader getReader(InputStream inStream) { return getReader(inStream, defaultCharset); } }