Here you can find the source of getReaderForFile(final Path file)
private static BufferedReader getReaderForFile(final Path file) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; import java.util.zip.GZIPInputStream; public class Main { private static BufferedReader getReaderForFile(final Path file) throws FileNotFoundException, IOException { final String filename = file.getFileName().toString().toLowerCase(); if (filename.endsWith(".gz")) { return new BufferedReader(new InputStreamReader( new GZIPInputStream(Files.newInputStream(file)))); }//from w ww .j a v a 2 s.c om return Files.newBufferedReader(file); } }