Android InputStream Copy copyRAWFile(InputStream inStream, File newfile)

Here you can find the source of copyRAWFile(InputStream inStream, File newfile)

Description

copy RAW File

Declaration

public static void copyRAWFile(InputStream inStream, File newfile) 

Method Source Code

//package com.java2s;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class Main {
    public static void copyRAWFile(InputStream inStream, File newfile) {
        try {/*  w w w  .j  av a2s. c  om*/
            FileOutputStream fs = new FileOutputStream(newfile);
            copyRAWFile(inStream, fs);
            fs.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void copyRAWFile(InputStream inStream,
            FileOutputStream outStream) {
        try {
            int bytesum = 0, byteread = 0;

            byte[] buffer = new byte[102400]; //100k buffer   
            while ((byteread = inStream.read(buffer)) != -1) {
                bytesum += byteread;
                System.out.println(bytesum);
                outStream.write(buffer, 0, byteread);
            }
            inStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. writeStream(InputStream input, OutputStream output)
  2. CopyStream(InputStream is, OutputStream os)
  3. CopyStream(InputStream is, OutputStream os)
  4. copyStream(InputStream src, OutputStream dest)
  5. copyAllBytes(InputStream in, OutputStream out)
  6. copyRAWFile(InputStream inStream, FileOutputStream outStream)