Java File Copy copyFile(File source, File target)

Here you can find the source of copyFile(File source, File target)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File source, File target) 

Method Source Code


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

import javax.swing.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

public class Main {
    public static void copyFile(File source, File target) {
        copyFile(source.toPath(), target.toPath());
    }//  ww w  . ja v a2  s. co m

    public static void copyFile(Path source, Path target) {
        try {
            Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(new JFrame(""), e.getMessage(), "something went wrong, very very wrong",
                    JOptionPane.ERROR_MESSAGE);
            e.printStackTrace();
        }
    }
}

Related

  1. copy(File from, File to)
  2. copyFile(File src, File dest, Component parentComponent, String message)
  3. copyFileFromFileSystem(String sourceFileName, File target)
  4. copyFiles(File file, File destPath)
  5. copyFiles(File fromDir, File toDir)