Here you can find the source of fromStream(InputStream stream)
Parameter | Description |
---|---|
stream | a parameter |
public static String fromStream(InputStream stream)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.util.Log; public class Main { /**//from www. j av a2s . c om * Read the whole stream into a string. The connection is not closed by this method. * @param stream * @return */ public static String fromStream(InputStream stream) { if (null == stream) { return null; } final StringBuilder sb = new StringBuilder(); final BufferedReader br = new BufferedReader(new InputStreamReader( stream), 256); String line; while (true) { try { line = br.readLine(); } catch (IOException e) { Log.e("StringUtil", "Error reading stream in HTTP get", e); break; } if (null == line) { break; } sb.append(line); } return sb.toString(); } }