Udostępnij za pośrednictwem


IPath.ToUri Method

Definition

Returns a URI to represent this path.

[Android.Runtime.Register("toUri", "()Ljava/net/URI;", "GetToUriHandler:Java.Nio.FileNio.IPathInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public Java.Net.URI? ToUri ();
[<Android.Runtime.Register("toUri", "()Ljava/net/URI;", "GetToUriHandler:Java.Nio.FileNio.IPathInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member ToUri : unit -> Java.Net.URI

Returns

URI

the URI representing this path

Attributes

Remarks

Returns a URI to represent this path.

This method constructs an absolute URI with a URI#getScheme() scheme equal to the URI scheme that identifies the provider. The exact form of the scheme specific part is highly provider dependent.

In the case of the default provider, the URI is hierarchical with a URI#getPath() path component that is absolute. The query and fragment components are undefined. Whether the authority component is defined or not is implementation dependent. There is no guarantee that the URI may be used to construct a java.io.File java.io.File. In particular, if this path represents a Universal Naming Convention (UNC) path, then the UNC server name may be encoded in the authority component of the resulting URI. In the case of the default provider, and the file exists, and it can be determined that the file is a directory, then the resulting URI will end with a slash.

The default provider provides a similar <em>round-trip</em> guarantee to the java.io.File class. For a given Pathp it is guaranteed that <blockquote>Paths#get(URI) Paths.get(p.toUri()).equals(p.#toAbsolutePath() toAbsolutePath())</blockquote> so long as the original Path, the URI, and the new Path are all created in (possibly different invocations of) the same Java virtual machine. Whether other providers make any guarantees is provider specific and therefore unspecified.

When a file system is constructed to access the contents of a file as a file system then it is highly implementation specific if the returned URI represents the given path in the file system or it represents a <em>compound</em> URI that encodes the URI of the enclosing file system. A format for compound URIs is not defined in this release; such a scheme may be added in a future release.

Java documentation for java.nio.file.Path.toUri().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to