Android Utililty Methods InputStream to String Convert

List of utility methods to do InputStream to String Convert

Description

The list of methods to do InputStream to String Convert are organized into topic(s).

Method

StringconvertToString(InputStream is, String encoding)
convert To String
if (null == is)
    return null;
BufferedReader reader = new BufferedReader(new InputStreamReader(
        is, encoding));
char cache[] = new char[2 * 512];
int cacheSize = -1;
StringBuilder buffer = new StringBuilder();
while ((cacheSize = reader.read(cache)) != -1) {
...
StringconvertToString(InputStream is, String encoding)
convert To String
if (null == is) {
    return null;
BufferedReader reader = new BufferedReader(new InputStreamReader(
        is, encoding));
char cache[] = new char[2 * 512];
int cacheSize = -1;
StringBuilder buffer = new StringBuilder();
...
StringconvertToString(InputStream is, String encoding)
convert To String
if (null == is)
    return null;
BufferedReader reader = new BufferedReader(new InputStreamReader(
        is, encoding));
char cache[] = new char[2 * 512];
int cacheSize = -1;
StringBuilder buffer = new StringBuilder();
while ((cacheSize = reader.read(cache)) != -1) {
...
Stringconvert(InputStream is)
convert
BufferedReader r = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line;
try {
    while ((line = r.readLine()) != null) {
        sb.append(line);
} catch (IOException e) {
...
byte[]readInputStream(InputStream inStream)
read Input Stream
ByteArrayOutputStream outSteam = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int len = 0;
while ((len = inStream.read(buffer)) != -1) {
    outSteam.write(buffer, 0, len);
outSteam.close();
inStream.close();
...
StringtoString(InputStream is)
to String
if (null == is)
    return null;
return toStringBuffer(is).toString();
StringBuffertoStringBuffer(InputStream is)
to String Buffer
if (null == is)
    return null;
StringBuffer buffer = new StringBuffer();
byte[] cache = new byte[1 * 1024];
for (int len; (len = is.read(cache)) != -1;) {
    buffer.append(new String(cache, 0, len));
is.close();
...
StringinputStream2String(InputStream in)
InputStream convert to string
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
    out.append(new String(b, 0, n));
return out.toString();
StringinputStreamToString(InputStream in)
input Stream To String
BufferedReader bufferedReader = new BufferedReader(
        new InputStreamReader(in));
StringBuilder stringBuilder = new StringBuilder();
String line = null;
while ((line = bufferedReader.readLine()) != null) {
    stringBuilder.append(line + "\n");
bufferedReader.close();
...
StringinputStreamToString(InputStream is)
input Stream To String
ByteArrayOutputStream byeArrayOutputStream = new ByteArrayOutputStream(
        8192);
byte[] buffer = new byte[8192];
int count = 0;
try {
    while ((count = is.read(buffer)) != -1) {
        byeArrayOutputStream.write(buffer, 0, count);
} finally {
    try {
        is.close();
    } catch (Exception ignore) {
String charset = "UTF-8";
String resultString = byeArrayOutputStream.toString(charset);
return resultString;