替代 Java 6 中的路径?
Alternative to Paths in Java 6?
我想获取Java6中当前目录的绝对路径,但不能使用Paths
。
String currentDirectory = Paths.get(".").toAbsolutePath().normalize().toString();
还有什么选择?
使用new File(".").getAbsolutePath()
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#getAbsolutePath()
Returns the absolute abstract pathname denoting the same file or directory as this abstract pathname
Since: 1.2
也许:
new File(".").getPath();
new File(".").getAbsolutePath();
new File(".").getCanonicalPath();
File f = new File("");
String currentDirectory = f.getAbsolutePath();
我想获取Java6中当前目录的绝对路径,但不能使用Paths
。
String currentDirectory = Paths.get(".").toAbsolutePath().normalize().toString();
还有什么选择?
使用new File(".").getAbsolutePath()
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#getAbsolutePath()
Returns the absolute abstract pathname denoting the same file or directory as this abstract pathname
Since: 1.2
也许:
new File(".").getPath();
new File(".").getAbsolutePath();
new File(".").getCanonicalPath();
File f = new File("");
String currentDirectory = f.getAbsolutePath();