Android Open Source - HealthTube Stream Utils






From Project

Back to project page HealthTube.

License

The source code is released under:

GNU General Public License

If you think the Android project HealthTube listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.healthtube;
/*www.  ja va2 s . co m*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;

public class StreamUtils {
   
    /**
     * A helper method to convert an InputStream into a String
     * @param inputStream
     * @return the String or a blank string if the IS was null
     * @throws IOException
     */
  
    public static String convertToString(InputStream inputStream) throws IOException {
        if (inputStream != null) {
            Writer writer = new StringWriter();
 
            char[] buffer = new char[1024];
            try {
                Reader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 1024);
                int n;
                while ((n = reader.read(buffer)) != -1) {
                    writer.write(buffer, 0, n);
                }
            } finally {
                inputStream.close();
            }
            return writer.toString();
        } else {
            return "";
        }
    }
}




Java Source Code List

com.healthtube.AdapterList.java
com.healthtube.GetYouTubeUserVideosTask.java
com.healthtube.ImageDownloader.java
com.healthtube.MainActivity.java
com.healthtube.StreamUtils.java
com.healthtube.Video.java