Is it possible to get a Path object from a java.io.File?
I know you can convert a path to a file using toFile() method, but I couldn\'t fin
From the documentation:
Paths associated with the default
providerare generally interoperable with thejava.io.Fileclass. Paths created by other providers are unlikely to be interoperable with the abstract path names represented byjava.io.File. ThetoPathmethod may be used to obtain a Path from the abstract path name represented by a java.io.File object. The resulting Path can be used to operate on the same file as thejava.io.Fileobject. In addition, thetoFilemethod is useful to construct aFilefrom theStringrepresentation of aPath.
(emphasis mine)
So, for toFile:
Returns a
Fileobject representing this path.
And toPath:
Returns a
java.nio.file.Pathobject constructed from the this abstract path.