Java InputStream to String getStreamContent(InputStream is)

Here you can find the source of getStreamContent(InputStream is)

Description

get Stream Content

License

LGPL

Declaration

public static String getStreamContent(InputStream is) throws IOException 

Method Source Code


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

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

public class Main {
    public static String getStreamContent(InputStream is) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        String c = "", line;
        while ((line = reader.readLine()) != null)
            c += "\n" + line;
        return c.substring(1);
    }/*from  w  w  w  . ja v a2 s.  c  om*/
}

Related

  1. getStreamAsString(final InputStream stream)
  2. getStreamAsString(InputStream input, String charset)
  3. getStreamAsString(InputStream is, String encoding)
  4. getStreamAsString(InputStream stream)
  5. getStreamAsString(InputStream stream, String charset)
  6. getStreamContent(InputStream stream, int bufferSize)
  7. getStreamContentAsString(InputStream is)
  8. getStreamContentAsString(InputStream is, String encoding)
  9. getStreamContents(final InputStream is)