Java File Copy nio copy(File src, File folder)

Here you can find the source of copy(File src, File folder)

Description

copy the file src to this folder

License

Open Source License

Parameter

Parameter Description

Declaration

public static void copy(File src, File folder) 

Method Source Code

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

import java.io.File;

import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

public class Main {
    /**/*from  w  w w . j a v  a2 s.c o m*/
     * copy the file src to this folder
     * @param src: source file
     * @param folder: destination folder
     */
    public static void copy(File src, File folder) {
        try {
            File dst = new File(folder, src.getName());
            Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. copy(File src, File dist)
  2. copy(File src, File dst)
  3. copy(File src, File dst)
  4. copy(File src, File dst)
  5. copy(File src, File dst)
  6. copy(File src, File target)
  7. copy(File src, File target)
  8. copy(File srcDir, File relSrcFile, File destDir, File relDestFile)
  9. copy(File srcfile, File destfile)