Here you can find the source of readLines(InputStream stream)
public static List<String> readLines(InputStream stream)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.util.*; public class Main { public static List<String> readLines(InputStream stream) { return splitMultiline(readString(stream), false); }//from w w w . j a v a 2 s.c o m public static List<String> splitMultiline(String text, boolean trimLines) { final List<String> result = new ArrayList<>(); final String[] lines = text.split("\\r\\n|\\n|\\r"); for (String line : lines) { result.add(trimLines ? line.trim() : line); } return result; } public static String readString(InputStream stream) { final Scanner s = new Scanner(stream, "UTF-8").useDelimiter("\\A"); return s.hasNext() ? s.next() : ""; } public static String readString(InputStream stream, String lineEndings) { return normalizeLineEndings(readString(stream), lineEndings); } private static String normalizeLineEndings(String text, String lineEndings) { return text.replaceAll("\\r\\n|\\n|\\r", lineEndings); } }