有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java文件访问被拒绝?

我有一个JFileChooser:

JOptionPane.showMessageDialog(null, "Navigate into the folder you would like to use for this application's files.");
final JFileChooser fcs = new JFileChooser();
int responses = fcs.showOpenDialog(fcs);
if (responses == JFileChooser.APPROVE_OPTION){
    dir = fcs.getCurrentDirectory().toString();
}else{
    System.exit(1);
}

当我试着写信给dir时,它说

java.io.FileNotFoundException: *Insert path here* (Access is denied)

无论我使用什么目录,它都能做到这一点,即使它是文档或桌面。我要做的就是制作一个名为maze的文件。txt,即使我没有使用文件选择器并在代码中给它一个目录,它也会给我同样的错误。发生了什么事?在我使用mkdir()后,它突然工作并停止工作;在另一个节目中


共 (0) 个答案