简体   繁体   English

IntelliJ Idea找不到目录

[英]IntelliJ Idea can't find directory

So, I recently switched from Eclipse to IntelliJ Idea, but for some reason when I run my java code, it can't find the directory where I store a file that I read in my program. 所以,我最近从Eclipse切换到IntelliJ Idea,但由于某种原因,当我运行我的java代码时,它找不到我存储我在程序中读取的文件的目录。 I know that it works in Eclipse and when I export it as a jar file, so why doesn't it work in IntelliJ Idea? 我知道它在Eclipse中工作,当我将它作为jar文件导出时,为什么它在IntelliJ Idea中不起作用? The specific error message is java.io.FileNotFoundException: /Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt (No such file or directory) 具体的错误信息是java.io.FileNotFoundException: /Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt (No such file or directory)

Okay, I figured out the problem. 好的,我发现了问题。 For some reason, IntelliJ set the working directory to the folder that contains the working directory. 出于某种原因,IntelliJ将工作目录设置为包含工作目录的文件夹。 Instead of going to /Users/Tyler/Google Drive/Java/Mac Workspace/Game/maps/default.txt like it was supposed to, it was skipping the game folder and going to /Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt . 它没有像它应该的那样进入/Users/Tyler/Google Drive/Java/Mac Workspace/Game/maps/default.txt ,而是跳过游戏文件夹并转到/Users/Tyler/Google Drive/Java/Mac Workspace/maps/default.txt To fix this, go to "Run" > "Edit Configurations...", and add on to the field titled "Working Directory." 要解决此问题,请转到“运行”>“编辑配置...”,然后添加到标题为“工作目录”的字段。

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

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