Java InputStream Read Line readLines(InputStream input)

Here you can find the source of readLines(InputStream input)

Description

read Lines

License

Open Source License

Declaration

public static List readLines(InputStream input) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List readLines(InputStream input) throws IOException {
        InputStreamReader reader = new InputStreamReader(input);
        return readLines(reader);
    }//from   ww w .j av a 2  s.co m

    public static List readLines(Reader input) throws IOException {
        BufferedReader reader = new BufferedReader(input);
        List list = new ArrayList();
        String line = reader.readLine();
        while (line != null) {
            list.add(line);
            line = reader.readLine();
        }

        closeQuietly(reader);
        return list;
    }

    public static void closeQuietly(java.io.Closeable writer) {
        try {
            if (writer != null) {
                writer.close();
            }
        } catch (IOException ioe) {
            // ignore
        }
    }
}

Related

  1. readLines(InputStream in, String encoding)
  2. readLines(InputStream input)
  3. readLines(InputStream input)
  4. readLines(InputStream input)
  5. readLines(InputStream input)
  6. readLines(InputStream input)
  7. readLines(InputStream input, String encoding)
  8. readLines(InputStream input, String encoding)
  9. readLines(InputStream input, String encoding)