Android InputStream to String Convert inputStream2String(InputStream inputStream)

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

Description

input Stream String

License

Open Source License

Declaration

public static String inputStream2String(InputStream inputStream)
        throws Exception 

Method Source Code

//package com.java2s;
/**//from ww  w. ja  v a2 s .c  om
 * Copyright (c) 2012 The Wiseserc. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class Main {

    public static String inputStream2String(InputStream inputStream)
            throws Exception {
        if (inputStream == null) {
            return null;
        }
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int count = 0;
        while ((count = inputStream.read(buffer)) >= 0) {
            outputStream.write(buffer, 0, count);
        }
        String convertedBuffer = new String(outputStream.toByteArray());
        outputStream.close();
        return convertedBuffer;
    }
}

Related

  1. streamToString(InputStream is)
  2. slurp(InputStream in)
  3. convertStreamToString(InputStream is)
  4. inStream2Str(InputStream inputStream, String encode)
  5. readIt(InputStream stream)
  6. InputStreamTOString(InputStream in)
  7. InputStreamTOString(InputStream in)
  8. InputStreamTOString(InputStream in)
  9. InputStreamTOString(InputStream in)