Back to project page android-reddit.
The source code is released under:
MIT License
If you think the Android project android-reddit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.pocketreddit.library.utils; //from w ww. j a v a 2 s . c o m import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class StreamUtils { private static StreamUtils instance; private StreamUtils() { } public static StreamUtils getInstance() { if (instance == null) { instance = new StreamUtils(); } return instance; } public String convertStreamToString(InputStream is) throws UtilsException { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; StringBuilder sb = new StringBuilder(); try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { throw new UtilsException("Couldn't read line from stream.", e); } finally { try { if (is != null) is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return sb.toString(); } }