我想检索Java6中当前目录的绝对路径,但不能使用Paths
。
String currentDirectory = Paths.get(".").toAbsolutePath().normalize().toString();
另一种选择是什么?
发布于 2017-05-22 09:15:44
使用new File(".").getAbsolutePath()
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#getAbsolutePath()
返回表示与此抽象路径名相同的文件或目录的绝对抽象路径名。 自: 1.2
发布于 2017-05-22 09:16:00
也许:
new File(".").getPath();
new File(".").getAbsolutePath();
new File(".").getCanonicalPath();
发布于 2017-05-22 09:17:25
File f = new File("");
String currentDirectory = f.getAbsolutePath();
https://stackoverflow.com/questions/44109027
复制相似问题