Why is there no Path constructor in java.nio.files.Path?

The Path class does not have a document constructor, but instances are created through. Paths.get( "...." )which is short for FileSystems.getDefault().getPath( "..." ). So can someone explain this design division?

+4
source share
1 answer

can someone explain this design decision?

This is due to the fact that JSR 203 allows you to output paths from more than FileSystem, unlike File, which is always associated with the JVM file system lives on. In JSR 203, this file system is called the default file system. You can get a link to it using FileSystems.getDefault().

Paths.get(), , FileSystems.getDefault().getPath(). Path , .getPath().

, a FileSystem () , :

.

+3

All Articles