Java InputStream Read Line readLines(InputStream stream)

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

Description

read Lines

License

Open Source License

Declaration

public static List<String> readLines(InputStream stream) throws IOException 

Method Source Code


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

import com.google.common.collect.Lists;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static List<String> readLines(File file) throws IOException {
        return readLines(new FileInputStream(file), "UTF-8");
    }/* ww w  .j a  va 2s . c  o m*/

    public static List<String> readLines(InputStream stream) throws IOException {
        return readLines(stream, "UTF-8");
    }

    public static List<String> readLines(InputStream stream, String encoding) throws IOException {
        List<String> list = Lists.newArrayList();
        try (Scanner scanner = new Scanner(stream, encoding)) {
            while (scanner.hasNext()) {
                list.add(scanner.nextLine());
            }
        }
        return list;
    }
}

Related

  1. readLines(InputStream is)
  2. readLines(InputStream is)
  3. readLines(InputStream is2, String encoding)
  4. readLines(InputStream is2, String encoding)
  5. readLines(InputStream stream)
  6. readLines(InputStream stream)
  7. readLines(InputStream stream, String charset)
  8. readLinesCommon(InputStream in)
  9. readLineSet(InputStream stream)