How to use relative path instead of absolute path?

前端 未结 4 1468
说谎
说谎 2020-12-06 07:33

So I am having a strange issue with Java.

I\'m reading a writing files, so the path is important to me. I would like all files to be written and read from the relati

4条回答
  •  难免孤独
    2020-12-06 07:56

    Java will save files relative to the current working directory. Are you inside you home directory when you run the program?

    If you always want files to be saved relative to the location of the Java files and not the current working directory, you need to find that directory and prepend it to get an absolute path.

提交回复
热议问题