集册 Java实例教程 复制文件和目录

复制文件和目录

欢马劈雪     最近更新时间:2020-01-02 10:19:05

568
复制选项在这里列出:


import java.io.IOException;
/**
 from
* N o w J a v a . c o m - 时  代  Java 
**/

import java.nio.file.Files;

import java.nio.file.LinkOption;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.nio.file.StandardCopyOption;


public class Main {

  public static void main(String[] args) throws Exception {


    Path copy_from = Paths.get("C:/folder1/folder0/folder9",

        "draw_template.txt");

    Path copy_to = Paths.get("C:/folder1/folder0/USOpen", copy_from/** 时 代 J a v a - nowjava.com 提 供 **/

        .getFileName().toString());


    try {


      Files.copy(copy_from, copy_to, StandardCopyOption.REPLACE_EXIST
展开阅读全文