Java FileInputStream Copy copyFile(final File fromFile, final File toFile)

Here you can find the source of copyFile(final File fromFile, final File toFile)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(final File fromFile, final File toFile)
            throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    public static void copyFile(final File fromFile, final File toFile)
            throws IOException {
        InputStream in = new FileInputStream(fromFile);
        OutputStream out = new FileOutputStream(toFile);

        byte[] buf = new byte[1024];
        int len;//  w  w w .j a v a  2 s.co m
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
        }
        in.close();
        out.close();
    }
}

Related

  1. copyfile(File srFile, File dtFile)
  2. copyFile(File target, File source)
  3. copyFile(File targetFile, File file)
  4. copyFile(File targetFile, File file)
  5. copyFile(final File from, final File to)
  6. copyFile(final File fromFile, final File toFile)
  7. copyFile(final File in, final File out)
  8. copyFile(final File oldfile, final File newfile)
  9. copyFile(final File source, final File dest)