Can a java program know its current directory?

Can a Java application know its own current directory I am referring to the results of PWD

For example, when executing

~/Documents/workspace/Project/bin $java com/foo/bar/baz/Runner files/text1.txt 
program should kNow ~/Documents/workspace/Project/bin


~/Documents/workspace/Project $java com/foo/bar/baz/Runner files/text1.txt 
program should kNow ~/Documents/workspace/Project

Solution

Perhaps this helps:

File cwd = new File(".");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>