read String From Stream : Stream « File « Android

read String From Stream

import java.nio.charset.Charset;

class Main {

    public static String readStringFromStream(InputStream stream) throws IOException {
        InputStreamReader isReader = new InputStreamReader(stream, Charset.forName("utf-8"));
        BufferedReader br = new BufferedReader(isReader);
        StringBuilder sb = new StringBuilder();
        String line;
        while ((line = br.readLine()) != null) {
        return sb.toString();


Related examples in the same category

1.Playing Back Audio Streams
2.Stream Proxy
3.Copy Stream
4.Ini File Stream Reader
5.Read InputStream fully to a string
6.Read Stream to byte array
7.Read stream Fully
8.Read InputStream with ByteArrayOutputStream
9.get Resource As Stream, Loads the resource from classpath
10.InputStream to byte array, copy Reader and Writer,
11.InputStream that notifies listeners of its progress.
12.String to InputStream
13.Context.getFileStreamPath To String To Bytes
16.Load/save Int Map Data
17.Write InputStream into a StringBuilder