Java InputStream to String asArrayString(InputStream response)

Here you can find the source of asArrayString(InputStream response)

Description

as Array String

License

Apache License

Declaration

public static String[] asArrayString(InputStream response) 

Method Source Code


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

import java.io.*;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static String[] asArrayString(InputStream response) {
        List<String> lines = new ArrayList<>();
        try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response))) {

            String line = null;/*from  www . jav  a2s.c  o  m*/
            while ((line = bufferedReader.readLine()) != null) {
                lines.add(line);
            }

            return lines.toArray(new String[lines.size()]);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getInputStreamAsString(final InputStream is, final String encoding)
  2. getInputStreamAsString(InputStream inStream)
  3. getInputStreamAsString(InputStream stream)
  4. getInputStreamContent(InputStream i, String encoding)