如何解决Filechooser 不复制到两个路径
我正在尝试添加一个小山文件图像和一个大山文件图像,由于某种原因,它们全部复制到一个路径中,这是我的代码 MountainListView.setonmousepressed(new EventHandler() {
@Override
public void handle(MouseEvent mouseEvent) {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) {
if (mouseEvent.getClickCount() == 2) {
FileChooser fileChooser = new FileChooser();
Window stage = null;
fileChooser.showOpenDialog(stage);
List<File> list = fileChooser.showOpenMultipleDialog(stage);
String path1 = "C:\\Users\\Dan\\eclipse-workspace\\mountainviewer\\src\\images\\small\\";
String path2 = "C:\\Users\\Dan\\eclipse-workspace\\mountainviewer\\src\\images\\large\\";
if (list != null) {
for (int i = 0; i < list.size(); i++) {
File file = list.get(i);
try {
if (i == 0) {
Files.copy(file.toPath(),(new File(path1 + file.getName())).toPath(),StandardcopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
// Todo Auto-generated catch block
e.printstacktrace();
}
};
}
}
}
}
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。