繁体   English   中英

java.io.FileNotFoundException:..(无此类文件或目录)

[英]java.io.FileNotFoundException: .. (No such file or directory)

我已经开发了一个Java项目,可以在Windows OS下在Eclipse上正常工作。 然后我想切换到Ubuntu。 我只是从Windows中获取了完整的工作区文件夹(包括运行所需的所有资源文件),并将其导入了Ubuntu的Eclipse。

最令人惊讶的是,我得到以下异常:

[ Test ] ERROR: unable to create myClass object. 
Check your implementation requirements!
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at Test.main(Test.java:183)
Caused by: java.io.FileNotFoundException: raw\file1.txt (No such file or directory)
...

但是这样的目录和文件实际上确实存在于当前路径中。

为什么会发生这种情况?

在任何项目中都使用File.separator而不是"/"

使用正斜杠“ /”,因为它在Windows和非Windows平台的文件路径中都可以使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM