Java File Copy nio copy(File from, File to)

Here you can find the source of copy(File from, File to)

Description

copy

License

Open Source License

Declaration

public static void copy(File from, File to) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

import java.nio.channels.*;

public class Main {

    public static void copy(File from, File to) {
        try (FileInputStream fin = new FileInputStream(from);
                FileChannel in = fin.getChannel();
                FileOutputStream fout = new FileOutputStream(to);
                FileChannel out = fout.getChannel()) {
            in.transferTo(0, from.length(), out);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }//  ww  w .j  a va2 s  .c o  m
    }
}

Related

  1. copy(File base_path, File in, File out)
  2. copy(File copied, File destination)
  3. copy(File file, File toDirectory)
  4. copy(File from, File to)
  5. copy(File from, File to)
  6. copy(File from, File to, final boolean recursive, Function excluded)
  7. copy(File in, File out)
  8. copy(File in, File out, boolean overwrite)
  9. copy(File inFile, File outFile)