Android InputStream Read readStringFromInputStream(InputStream is)

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

Description

read String From Input Stream

License

Open Source License

Declaration

public static String readStringFromInputStream(InputStream is)
            throws IOException 

Method Source Code

//package com.java2s;
/* //from  w  ww  .  j a  va 2  s  . co  m
 * SWRVE CONFIDENTIAL
 * 
 * (c) Copyright 2010-2014 Swrve New Media, Inc. and its licensors.
 * All Rights Reserved.
 * 
 * NOTICE: All information contained herein is and remains the property of Swrve
 * New Media, Inc or its licensors.  The intellectual property and technical
 * concepts contained herein are proprietary to Swrve New Media, Inc. or its
 * licensors and are protected by trade secret and/or copyright law.
 * Dissemination of this information or reproduction of this material is
 * strictly forbidden unless prior written permission is obtained from Swrve.
 */

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

public class Main {
    public static String readStringFromInputStream(InputStream is)
            throws IOException {
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));

        StringBuilder body = new StringBuilder();
        String line;

        while ((line = rd.readLine()) != null) {
            body.append(line);
        }

        return body.toString();
    }
}

Related

  1. readInputStream(InputStream is)
  2. readInputStreamContent(InputStream inputStream)
  3. readInt(InputStream stream)
  4. readLong(InputStream in, final int fitInBytes)
  5. readShort(InputStream stream)
  6. readTextInputStream(InputStream is)
  7. readData(InputStream inSream, String charsetName)
  8. skip(InputStream stream, int numBytes)
  9. dealResponseResult(InputStream in)