Here you can find the source of readFile(File file)
public static List<String> readFile(File file) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.zip.GZIPInputStream; public class Main { /**/* www . j av a 2 s . com*/ * Reads the content of the provided file. */ public static List<String> readFile(File file) throws IOException { InputStream is = new FileInputStream(file); if (file.getName().toLowerCase().endsWith(".gz")) is = new GZIPInputStream(is); List<String> lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { String line = reader.readLine(); while (line != null) { lines.add(line); line = reader.readLine(); } } return lines; } }