Compartir a través de


File.ToURI Method

Definition

Constructs a file: URI that represents this abstract pathname.

[Android.Runtime.Register("toURI", "()Ljava/net/URI;", "GetToURIHandler")]
public virtual Java.Net.URI ToURI ();
[<Android.Runtime.Register("toURI", "()Ljava/net/URI;", "GetToURIHandler")>]
abstract member ToURI : unit -> Java.Net.URI
override this.ToURI : unit -> Java.Net.URI

Returns

URI

An absolute, hierarchical URI with a scheme equal to "file", a path representing this abstract pathname, and undefined authority, query, and fragment components

Attributes

Remarks

Constructs a file: URI that represents this abstract pathname.

The exact form of the URI is system-dependent. If it can be determined that the file denoted by this abstract pathname is a directory, then the resulting URI will end with a slash.

For a given abstract pathname f, it is guaranteed that

<blockquote> new #File(java.net.URI) File(&nbsp;f.toURI()).equals(&nbsp;f.#getAbsoluteFile() getAbsoluteFile()) </blockquote>

so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. Due to the system-dependent nature of abstract pathnames, however, this relationship typically does not hold when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.

Note that when this abstract pathname represents a UNC pathname then all components of the UNC (including the server name component) are encoded in the URI path. The authority component is undefined, meaning that it is represented as null. The Path class defines the Path#toUri toUri method to encode the server name in the authority component of the resulting URI. The #toPath toPath method may be used to obtain a Path representing this abstract pathname.

Added in 1.4.

Java documentation for java.io.File.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