简体   繁体   中英

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. 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? The specific error message is 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. 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 . To fix this, go to "Run" > "Edit Configurations...", and add on to the field titled "Working Directory."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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