|Modifier and Type||Method and Description|
Converts a path string, or a sequence of strings that when joined form a path string, to a
Converts the given URI to a
moredoes not specify any elements then the value of the
firstparameter is the path string to convert. If
morespecifies one or more elements then each non-empty string, including
first, is considered to be a sequence of name elements (see
Path) and is joined to form a path string. The details as to how the Strings are joined is provider specific but typically they will be joined using the
name-separatoras the separator. For example, if the name separator is "
getPath("/foo","bar","gus")is invoked, then the path string
"/foo/bar/gus"is converted to a
Pathrepresenting an empty path is returned if
firstis the empty string and
moredoes not contain any non-empty strings.
Note that while this method is very convenient, using it will imply
an assumed reference to the default
FileSystem and limit the
utility of the calling code. Hence it should not be used in library code
intended for flexible reuse. A more flexible alternative is to use an
Path instance as an anchor, such as:
Path dir = ... Path path = dir.resolve("file");
first- the path string or initial part of the path string
more- additional strings to be joined to form the path string
InvalidPathException- if the path string cannot be converted to a
This method iterates over the
installed providers to locate the provider that is identified by the
scheme of the given URI. URI schemes are
compared without regard to case. If the provider is found then its
getPath method is invoked to convert the
In the case of the default provider, identified by the URI scheme
"file", the given URI has a non-empty path component, and undefined query
and fragment components. Whether the authority component may be present
is platform specific. The returned
Path is associated with the
default file system.
The default provider provides a similar round-trip guarantee
File class. For a given
Path p it
is guaranteed that
Paths.get(p.so long as the original
URI, and the new
Pathare all created in (possibly different invocations of) the same Java virtual machine. Whether other providers make any guarantees is provider specific and therefore unspecified.
uri- the URI to convert
IllegalArgumentException- if preconditions on the
uriparameter do not hold. The format of the URI is provider specific.
FileSystemNotFoundException- The file system, identified by the URI, does not exist and cannot be created automatically, or the provider identified by the URI's scheme component is not installed
SecurityException- if a security manager is installed and it denies an unspecified permission to access the file system
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2018, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.