Android InputStream Save writeToString(InputStream stream)

Here you can find the source of writeToString(InputStream stream)

Description

write To String

Declaration

public static String writeToString(InputStream stream)
            throws java.io.IOException 

Method Source Code

//package com.java2s;

import java.io.BufferedReader;

import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String writeToString(InputStream stream)
            throws java.io.IOException {
        StringBuffer fileData = new StringBuffer(1000);
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                stream, "utf-8"));
        char[] buf = new char[1024];
        int numRead = 0;
        while ((numRead = reader.read(buf)) != -1) {
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);//from   w w  w. j  a  v  a 2 s . c om
            buf = new char[1024];
        }
        reader.close();
        return fileData.toString();
    }
}

Related

  1. saveToLocal(InputStream in, String filePath)
  2. writerFromInputStream(InputStream stream, String path, String fileName)
  3. writeFile(File outputFile, InputStream inputStream)
  4. saveFile(Context context, String fileName, InputStream inputStream)
  5. writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag)
  6. saveInputStreamAsFile(InputStream inputStream, File target)
  7. saveStream(InputStream is, String savePath)
  8. saveTmpFile(InputStream is)
  9. toBase64OutputStream(InputStream is, OutputStream os)