Java 文件访问被拒绝?

Java 文件访问被拒绝?,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

我有一个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()后,它突然工作并停止工作;在另一个程序中…

您使用的是哪个操作系统?这可能是一个小程序吗?