Here you can find the source of readLines(InputStream is)
public static List<String> readLines(InputStream is)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> readLines(File file) { List<String> fileContent = new ArrayList<String>(); try {/*from w w w . j a v a 2 s . c om*/ if (file.isFile() && file.exists()) { InputStreamReader read = new InputStreamReader(new FileInputStream(file), "utf-8"); BufferedReader reader = new BufferedReader(read); String line; while ((line = reader.readLine()) != null) { fileContent.add(line); } read.close(); } } catch (Exception e) { e.printStackTrace(); } return fileContent; } public static List<String> readLines(String fileName) { File file = new File(fileName); return readLines(file); } public static List<String> readLines(InputStream is) { List<String> fileContent = new ArrayList<String>(); try { InputStreamReader read = new InputStreamReader(is, "utf-8"); BufferedReader reader = new BufferedReader(read); String line; while ((line = reader.readLine()) != null) { fileContent.add(line); } read.close(); is.close(); } catch (Exception e) { e.printStackTrace(); } return fileContent; } public static List<String> readLines(File file, String encoding) { List<String> lines = new ArrayList<String>(); try { if (file.isFile() && file.exists()) { InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding); BufferedReader reader = new BufferedReader(read); String line; while ((line = reader.readLine()) != null) { lines.add(line); } read.close(); } } catch (Exception e) { e.printStackTrace(); } return lines; } public static List<String> readLines(String fileName, String encoding) { File file = new File(fileName); return readLines(file, encoding); } }