Java InputStream Read inputStreamToList(InputStream stream)

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

Description

input Stream To List

License

Open Source License

Declaration

private static List<String> inputStreamToList(InputStream stream) 

Method Source Code


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

import java.io.BufferedReader;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.List;

public class Main {
    private static List<String> inputStreamToList(InputStream stream) {
        List<String> list = new ArrayList<>();
        try {//from  w w  w .  j ava  2  s. c  o  m
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            String line;
            while ((line = reader.readLine()) != null) {
                list.add(line);
            }
        } catch (Exception ex) {
            throw new RuntimeException("Can't read Input Stream: " + ex.getMessage());
        }
        return list;
    }
}

Related

  1. getInputStreamReader(InputStream in, String charset)
  2. getInputStreamReaderAsResource(Class clazz, String fileName)
  3. getInputStreamString(final InputStream in)
  4. getInputStreamToBytes(InputStream is)
  5. inputStreamReadBytesUntil(int endInd, InputStream is, byte[] buf, int off)