Android InputStream Save doOutputFile(InputStream is, String filename)

Here you can find the source of doOutputFile(InputStream is, String filename)

Description

do Output File

Declaration

private static void doOutputFile(InputStream is, String filename)
            throws IOException, FileNotFoundException 

Method Source Code

//package com.java2s;

import java.io.BufferedOutputStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import java.util.List;

public class Main {
    private static final int BUFFER_SIZE = 8192;
    protected static byte buf[] = new byte[BUFFER_SIZE];
    private static List<Object> mTmpBuffer = new ArrayList<Object>();

    private static void doOutputFile(InputStream is, String filename)
            throws IOException, FileNotFoundException {
        FileOutputStream os = new FileOutputStream(filename);
        BufferedOutputStream bos = new BufferedOutputStream(os, BUFFER_SIZE);
        int len;/* w  ww.j  a  va  2  s .  c  o  m*/
        while ((len = is.read(buf, 0, BUFFER_SIZE)) > 0) {
            bos.write(buf, 0, len);
        }
        bos.flush();
        bos.close();
        os.close();
        mTmpBuffer.add(os);
        mTmpBuffer.add(bos);
    }
}

Related

  1. saveInputStreamAsFile(InputStream inputStream, File target)
  2. saveStream(InputStream is, String savePath)
  3. saveTmpFile(InputStream is)
  4. toBase64OutputStream(InputStream is, OutputStream os)
  5. toOutputStream(InputStream is, OutputStream os)
  6. writeFile(File file, InputStream inStream)