Java新手问题:文件类中getAbsolutePath()和getcanonicalPath()之间有什么不同.我无法从文件中得到意义.在下面的代码中,它们的输出是相同的.
public class copyFile {
public static void main(String[] args) throws IOException {
File inputFile = new File("/home/kit.ho/");
System.out.println("get AbsolutePath");
System.out.println(inputFile.getAbsolutePath());
System.out.println("get CanonicalPath");
System.out.println(inputFile.getCanonicalPath());
}
}
Run Code Online (Sandbox Code Playgroud)
Jon*_*eet 21
假设/home实际上是一个符号链接/usr/home.然后getAbsolutePath仍将返回,/home/kit.ho/而getCanonicalPath将解析符号链接并返回/usr/home/kit.ho/.
| 归档时间: |
|
| 查看次数: |
6976 次 |
| 最近记录: |