gpt4 book ai didi

java - 类文件方法 toPath() 的 NoSuchMethodError

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:14:54 24 4
gpt4 key购买 nike

我正在尝试使用以下代码将文件 StandardQuestions.csv 复制到新文件名:

String standardQuestions = "StandardQuestions.csv";
if(new File(standardQuestions).exists()){
try{
Path source = new File(standardQuestions).toPath();
Path dest = new File(filename).toPath();
Files.copy(source,dest);
}
catch(java.io.IOException e){JOptionPane.showMessageDialog(this,"Error: Input/Output exception.");}
}

我在行 Path source = new File(standardQuestions).toPath(); 上收到错误消息我的错误消息是 NoSuchMethodError,在类 File 中找不到方法 toPath。 File类怎么可能没有这个方法呢?该程序在 3-4 台机器上运行正确,但对于一个用户,它总是抛出此错误。知道是什么原因造成的吗?是否需要任何其他信息来回答这个问题?

最佳答案

由于 PathtoPath() 是最近添加到 Java 库中的(它们已添加到 Java 7 中),我会确保您正在使用跨机器的相同版本的 Java。

关于java - 类文件方法 toPath() 的 NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9570728/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com