Java InputStream to String InputStreamToStringArray(InputStream input_stream)

Here you can find the source of InputStreamToStringArray(InputStream input_stream)

Description

Input Stream To String Array

License

Open Source License

Declaration

public static String[] InputStreamToStringArray(InputStream input_stream) throws Exception 

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.LinkedList;
import java.util.List;

public class Main {
    public static String[] InputStreamToStringArray(InputStream input_stream) throws Exception {
        return InputStreamToStringList(input_stream).toArray(new String[0]);
    }// w  w  w.  j  a  v  a2  s  .  c o  m

    public static List<String> InputStreamToStringList(InputStream input_stream) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(input_stream, "UTF-8"));
        List<String> lstRet = new LinkedList<>();

        String sBuffer = br.readLine();
        while (sBuffer != null) {
            lstRet.add(sBuffer);
            sBuffer = br.readLine();
        }

        return lstRet;
    }
}

Related

  1. inputStreamToString(InputStream is)
  2. inputStreamToString(InputStream is)
  3. inputStreamToString(InputStream is)
  4. inputStreamToString(InputStream s)
  5. inputStreamToString(InputStream stream)
  6. inputStreamToStringBuffer(InputStream stream)
  7. inputStreamToStringBuilder(final InputStream inputStream, final String charset)
  8. inputStreamToStringBuilder(InputStream in, int minimumCapacity)
  9. inputStreamToText(InputStream inputStream)