Here you can find the source of getStreamLines(final InputStream is)
public static List<String> getStreamLines(final InputStream is) throws IllegalArgumentException
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { private static final String DEFAULT_ENCODING = "UTF-8"; public static List<String> getStreamLines(final InputStream is) throws IllegalArgumentException { return getStreamLines(is, DEFAULT_ENCODING); }//from w ww. j ava 2s .c o m public static List<String> getStreamLines(final InputStream is, final String enc) throws IllegalArgumentException { List<String> lines = new ArrayList<>(); Scanner scanner = new Scanner(is, enc).useDelimiter("\r?\n"); while (scanner.hasNext()) { try { lines.add(scanner.next()); } catch (NoSuchElementException e) { break; } } scanner.close(); return lines; } }