Android InputStream Copy copyRAWFile(InputStream inStream, FileOutputStream outStream)

Here you can find the source of copyRAWFile(InputStream inStream, FileOutputStream outStream)

Description

copy RAW File

Declaration

public static void copyRAWFile(InputStream inStream,
            FileOutputStream outStream) 

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 {/*from w w w  .j a  va  2s . c o  m*/
            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. CopyStream(InputStream is, OutputStream os)
  2. CopyStream(InputStream is, OutputStream os)
  3. copyStream(InputStream src, OutputStream dest)
  4. copyAllBytes(InputStream in, OutputStream out)
  5. copyRAWFile(InputStream inStream, File newfile)