我正在尝试使用以下代码将文件 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 台机器上正常运行,但对于一个用户,它总是抛出此错误。知道是什么原因造成的吗?是否需要任何其他信息来回答这个问题?