Back to project page growthpush-android.
The source code is released under:
Apache License
If you think the Android project growthpush-android 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.growthpush.utils; // w ww . j av a 2 s . com import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import android.os.Build; public class IOUtils { public static String toString(InputStream inputStream) throws IOException { InputStreamReader objReader = new InputStreamReader(inputStream); BufferedReader bufferedReader = new BufferedReader(objReader); StringBuilder stringBuilder = new StringBuilder(); try { String line = null; while ((line = bufferedReader.readLine()) != null) { stringBuilder.append(line); } return stringBuilder.toString(); } catch (IOException e) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) throw new IOException("Failed to convert InputStream to String.", e); else throw new IOException("Failed to convert InputStream to String."); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) throw new IOException("Failed to close InputStream.", e); else throw new IOException("Failed to close InputStream."); } } } } }