Java InputStream Read Line readLines(InputStream input, String encoding)

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

Description

read Lines

License

Apache License

Declaration

public static List readLines(InputStream input, String encoding)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.io.Reader;

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  w w  w  .  jav a2  s.  c  o m

    public static List readLines(File file) throws IOException {
        Reader reader = new FileReader(file);
        return readLines(reader);
    }

    public static List readLines(InputStream input, String encoding)
            throws IOException {
        if (encoding == null) {
            return readLines(input);
        }
        InputStreamReader reader = new InputStreamReader(input, encoding);
        return readLines(reader);
    }

    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();
        }
        return list;
    }
}

Related

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