java.io.ioexception: file exists_无法使文件java.io.IOException:没有这样的文件或目录
我试图在文件系统上创建一个文件,但是我不断得到这个异常:java.io.IOException: No such file or directory我有一个现有的目录,我正在尝试写一个文件到该目录。// I have also tried this below, but get same error// new File(System.getProperty("user.home") + "/.f
我试图在文件系统上创建一个文件,但是我不断得到这个异常:
java.io.IOException: No such file or directory
我有一个现有的目录,我正在尝试写一个文件到该目录。
// I have also tried this below, but get same error
// new File(System.getProperty("user.home") + "/.foo/bar/" + fileName);
File f = new File(System.getProperty("user.home") + "/.foo/bar/", fileName);
if (f.exists() && !f.canWrite())
throw new IOException("Kan ikke skrive til filsystemet " + f.getAbsolutePath());
if (!f.isFile()) {
f.createNewFile(); // Exception here
} else {
f.setLastModified(System.currentTimeMillis());
}
获取异常:
java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:883)`
我有对该路径的写入权限,但是该文件未创建。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)