java 无法创建新文件:设备未准备好
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13343502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot Create New file: The device is not ready
提问by ErrorNotFoundException
I am Creating a new File using Java but am getting tis exception:
我正在使用 Java 创建一个新文件,但出现异常:
Exception in thread "main" java.io.IOException: The device is not ready
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:947)
at pdfconverter.PdfConverter.main(PdfConverter.java:96)
Java Result: 1
Java 结果:1
In My line 96 is this Condition:
在我的第 96 行是这个条件:
if (!logfile.exists()) {
logfile.createNewFile();//line 96
}
I have used this amny times before and I do not understand what's going on Because I am logged in as Administrator. Please Help.
我以前用过这个很多次,我不明白发生了什么,因为我以管理员身份登录。请帮忙。
回答by ErrorNotFoundException
The problem was the Path, which was not found because someone had renamed the drive letter from F to D. Sorry for not noticing that In time.
问题是路径,没有找到,因为有人将驱动器号从 F 重命名为 D。抱歉没有及时注意到。
回答by JIGNESH PARMAR
If this kind of error occurred in your net-beans while you deploying an app then open this path C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.3\conf\Catalina\localhost
(it might be different as your tomcat installation dir). There is web.xml you should open it and check docBase="D:\xyz\web\target\web"
is configured by proper project base directory or not.
如果在部署应用程序时在您的 net-beans 中发生此类错误,请打开此路径C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.3\conf\Catalina\localhost
(它可能与您的 tomcat 安装目录不同)。有 web.xml 你应该打开它并检查docBase="D:\xyz\web\target\web"
是否由正确的项目基目录配置。