As I understand the different getPath,getAbsolutePath and getCanonicalPath what I don't understand why does absolute path is different from Canonical path - in the Canonical path I see /private
prefix which doesn't exist in absolute path
I run the below code in scala
object ScalaDemo {
def main(args: Array[String]): Unit = {
val dir = Files.createTempDirectory("test").toFile
println("dir.getPath:" + dir.getPath)
println("dir.getAbsolutePath:" + dir.getAbsolutePath)
println("dir.getCanonicalPath:" + dir.getCanonicalPath)
}
}
I got this output:
dir.getPath:/var/folders/fq/8q8jpphd2qb2_07p4h2kzn0m0000gn/T/test3084029786797422592
dir.getAbsolutePath:/var/folders/fq/8q8jpphd2qb2_07p4h2kzn0m0000gn/T/test3084029786797422592
dir.getCanonicalPath:/private/var/folders/fq/8q8jpphd2qb2_07p4h2kzn0m0000gn/T/test3084029786797422592
Can see that the Canonical path have /private
prefix - Why is that?
I also run ls -al
on the absolute path output to see if there is symlink but didn't find any. I'm using mac with scala 2.9.1