Java InputStream to String inputStream2String(InputStream in)

Here you can find the source of inputStream2String(InputStream in)

Description

input Stream String

License

Open Source License

Declaration

public static String inputStream2String(InputStream in)
            throws IOException 

Method Source Code

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static String inputStream2String(InputStream in)
            throws IOException {
        StringBuffer out = new StringBuffer();
        byte[] b = new byte[4096];
        for (int n; (n = in.read(b)) != -1;) {
            out.append(new String(b, 0, n));
        }//from   www  .ja  v a2  s  .  c  om
        return out.toString();
    }
}

Related

  1. getStreamContent(InputStream stream, int bufferSize)
  2. getStreamContentAsString(InputStream is)
  3. getStreamContentAsString(InputStream is, String encoding)
  4. getStreamContents(final InputStream is)
  5. inputStream2String(InputStream in)
  6. inputStream2String(InputStream in)
  7. InputStream2String(InputStream in, String encoding)
  8. InputStream2String(InputStream in_st, String charset)
  9. inputStream2String(InputStream inputstream)