java – file. Createnewfile() IOException “no such file or directory”
•
Java
Although java coding has this problem: file Createnewfile() throws IOException "no such file or directory" Check out other answers, but it doesn't seem to help Any ideas
Solution
You may be trying to create a file in a directory that does not exist
Use mkdirs() to first create any missing parent directory
File file = new File("foo/bar.txt") file.getParentFile().mkdirs(); file.createNewFile();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码