java.io.FileNotFoundException:..(没有这样的文件或目录)

Joh*_*han 0 java linux windows filenotfoundexception

我在Windows操作系统下开发了一个正确处理Eclipse的Java项目.然后我想切换到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)
...
Run Code Online (Sandbox Code Playgroud)

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

为什么会这样?

Kin*_*tsu 8

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

  • 我会说"在任何项目中". (4认同)