Java FileInputStream Copy copyFileUsingStream(File source, File dest)

Here you can find the source of copyFileUsingStream(File source, File dest)

Description

copy File Using Stream

License

LGPL

Declaration

public static void copyFileUsingStream(File source, File dest) throws IOException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.*;

public class Main {
    public static void copyFileUsingStream(File source, File dest) throws IOException {
        InputStream is = null;/*from   w  ww. j  a v  a  2  s.c om*/
        OutputStream os = null;
        try {
            is = new FileInputStream(source);
            os = new FileOutputStream(dest);
            byte[] buffer = new byte[1024];
            int length;
            while ((length = is.read(buffer)) > 0) {
                os.write(buffer, 0, length);
            }
        } finally {
            is.close();
            os.close();
        }
    }
}

Related

  1. copyFileToStream(File file, OutputStream stream)
  2. copyFileToStream(File file, OutputStream stream)
  3. copyFileToString(java.io.File f)
  4. copyFileToZip(final ZipOutputStream zos, final byte[] readBuffer, final File file, final int bytesInOfZip)
  5. copyFileUsingFileStreams(final File source, final File dest)
  6. copyFileUsingStream(String source_path, String dest_path)