且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

系统找不到Kotlin中指定的文件

更新时间:2023-09-18 16:58:10

如果传递不带路径的文件名,则JVM将在当前工作目录中查找该文件,而不是进行呼叫的类的package文件夹.因此,要使用相对路径,必须首先找出程序的工作目录,如果从intelliJ中运行它,则该目录通常应该是项目的根文件夹.

If you pass a filename without a path, the JVM is going to look for that file in the current working directory, not the package folder of the class you're making the call from. So, to use relative paths, you have to first find out the working directory of your program, which should usually be the root folder of the project if you're running it from intelliJ.