【发布时间】:2023-03-29 08:15:01
【问题描述】:
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;`enter code here`
public class Mover {
public static void main(String[] args) throws IOException, InterruptedException {
URL source = Mover.class.getResource("host");
source.toString();
String destino = "C:\\users\\jerso\\desktop\\";
Path sourceFile = Paths.get(source,"hosts");//here an error occurs.
Path targetFile = Paths.get(destino,"hosts");
Files.copy(sourceFile, targetFile,StandardCopyOption.REPLACE_EXISTING);
enter code here
}
}
我不知道在这里做什么->>Path sourceFile = Paths.get(source,"hosts"); Paths 类型中的 get(String, String...) 方法不适用于参数 (URL, String.
【问题讨论】:
-
你遇到什么错误?
标签: java