我通过阅读一些相关文本来了解两者之间的差异.但我很好奇为什么getCanonicalPath()抛出检查异常而getAbsolutePath()不抛出任何东西?
解决方法
But I am curIoUs that why
getCanonicalPath()
throws checked exception whilegetAbsolutePath()
does not throw any?
它说明为什么在the documentation for getCanonicalPath
:
IOException
– If an I/O error occurs,which is possible because the construction of the canonical pathname may require filesystem queries