Java Utililty Methods InputStream Read Line

List of utility methods to do InputStream Read Line

Description

The list of methods to do InputStream Read Line are organized into topic(s).

Method

ListreadLines(InputStream in)
read Lines
BufferedReader br = new BufferedReader(new InputStreamReader(in, "ASCII"));
List<String> lines = new ArrayList<String>();
for (String line = br.readLine(); line != null; line = br.readLine())
    lines.add(line);
return lines;
ListreadLines(InputStream in)
Read the supplied input stream and return a list of lines read.
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
ArrayList<String> lines = new ArrayList<String>();
String line = null;
while ((line = reader.readLine()) != null) {
    lines.add(line);
return lines;
String[]readLines(InputStream in, int maxArraySize)
read Lines
try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) {
    List<String> strings = new ArrayList<String>();
    String s = br.readLine();
    while (s != null && (maxArraySize < 0 || strings.size() < maxArraySize)) {
        strings.add(s);
        s = br.readLine();
    return strings.toArray(new String[strings.size()]);
...
ListreadLines(InputStream in, String charset)
Reads lines from an input stream.
BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
ArrayList<String> result = new ArrayList<String>();
String line;
while ((line = reader.readLine()) != null) {
    result.add(line);
return result;
ListreadLines(InputStream in, String encoding)
get the content from an InputStream as a list of strings
InputStreamReader reader = null;
if (encoding == null) {
    reader = new InputStreamReader(in);
} else {
    reader = new InputStreamReader(in, encoding);
BufferedReader br = new BufferedReader(reader);
List<String> lines = new ArrayList<String>();
...
ListreadLines(InputStream input)
Get the contents of an InputStream as a list of Strings, one entry per line, using the default character encoding of the platform.
InputStreamReader reader = new InputStreamReader(input);
return readLines(reader);
ListreadLines(InputStream input)
read Lines
List<String> lines = new ArrayList<String>();
try {
    BufferedReader reader = new BufferedReader(new InputStreamReader(input));
    try {
        String line;
        while ((line = reader.readLine()) != null) {
            lines.add(line);
    } catch (IOException e) {
        throw new RuntimeException("Reading file failed", e);
    } finally {
        reader.close();
} catch (IOException e) {
    throw new RuntimeException("Error closing reader", e);
return lines;
ListreadLines(InputStream input)
Get the contents of an InputStream as a list of Strings, one entry per line, using the default character encoding of the platform.
InputStreamReader reader = new InputStreamReader(input);
return readLines(reader);
ListreadLines(InputStream input)
Get the contents of an InputStream as a list of Strings, one entry per line, using the default character encoding of the platform.
InputStreamReader reader = new InputStreamReader(input);
return readLines(reader);
ListreadLines(InputStream input)
read Lines
InputStreamReader reader = new InputStreamReader(input);
return readLines(reader);