Here you can find the source of createReader(Path p, Charset cs)
public static Reader createReader(Path p, Charset cs) throws IOException
//package com.java2s; /*/*from ww w . jav a2 s . co m*/ * Copyright 2012-2015 Johns Hopkins University HLTCOE. All rights reserved. * See LICENSE in the project root directory. */ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.zip.GZIPInputStream; public class Main { public static Reader createReader(Path p, Charset cs) throws IOException { InputStream is = Files.newInputStream(p); InputStream gis; if (p.toString().endsWith(".gz")) gis = new GZIPInputStream(is); else gis = is; Reader r = new InputStreamReader(gis, cs); return r; } public static Reader createReader(Path p) throws IOException { return createReader(p, StandardCharsets.UTF_8); } }