IPath Interface

Definition

An object that may be used to locate a file in a file system.

[Android.Runtime.Register("java/nio/file/Path", "", "Java.Nio.FileNio.IPathInvoker", ApiSince=26)]
public interface IPath : IDisposable, Java.Interop.IJavaPeerable, Java.Lang.IComparable, Java.Lang.IIterable, Java.Nio.FileNio.IWatchable
[<Android.Runtime.Register("java/nio/file/Path", "", "Java.Nio.FileNio.IPathInvoker", ApiSince=26)>]
type IPath = interface
    interface IComparable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IIterable
    interface IWatchable
Attributes
Implements

Remarks

An object that may be used to locate a file in a file system. It will typically represent a system dependent file path.

A Path represents a path that is hierarchical and composed of a sequence of directory and file name elements separated by a special separator or delimiter. A <em>root component</em>, that identifies a file system hierarchy, may also be present. The name element that is <em>farthest</em> from the root of the directory hierarchy is the name of a file or directory. The other name elements are directory names. A Path can represent a root, a root and a sequence of names, or simply one or more name elements. A Path is considered to be an empty path if it consists solely of one name element that is empty. Accessing a file using an empty path is equivalent to accessing the default directory of the file system. Path defines the #getFileName() getFileName, #getParent getParent, #getRoot getRoot, and #subpath subpath methods to access the path components or a subsequence of its name elements.

In addition to accessing the components of a path, a Path also defines the #resolve(Path) resolve and #resolveSibling(Path) resolveSibling methods to combine paths. The #relativize relativize method that can be used to construct a relative path between two paths. Paths can be #compareTo compared, and tested against each other using the #startsWith startsWith and #endsWith endsWith methods.

This interface extends Watchable interface so that a directory located by a path can be #register registered with a WatchService and entries in the directory watched.

<b>WARNING:</b> This interface is only intended to be implemented by those developing custom file system implementations. Methods may be added to this interface in future releases.

<h2>Accessing Files</h2>

Paths may be used with the Files class to operate on files, directories, and other types of files. For example, suppose we want a java.io.BufferedReader to read text from a file "access.log". The file is located in a directory "logs" relative to the current working directory and is UTF-8 encoded.

Path path = FileSystems.getDefault().getPath("logs", "access.log");
                BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);

"interop"><h2>Interoperability</h2>

Paths associated with the default java.nio.file.spi.FileSystemProvider provider are generally interoperable with the java.io.File java.io.File class. Paths created by other providers are unlikely to be interoperable with the abstract path names represented by java.io.File. The java.io.File#toPath toPath method 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 the java.io.File object. In addition, the #toFile toFile method is useful to construct a File from the String representation of a Path.

<h2>Concurrency</h2>

Implementations of this interface are immutable and safe for use by multiple concurrent threads.

Added in 1.7.

Java documentation for java.nio.file.Path.

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.

Properties

FileName
FileSystem
Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
IsAbsolute
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
NameCount
Parent
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)
Root

Methods

CompareTo(IPath)

Compares two abstract paths lexicographically.

CompareTo(Object)

Compares this object with the specified object for order.

(Inherited from IComparable)
Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
EndsWith(IPath)

Tests if this path ends with the given path.

EndsWith(String)

Tests if this path ends with a Path, constructed by converting the given path string, in exactly the manner specified by the #endsWith(Path) endsWith(Path) method.

Equals(Object)

Tests this path for equality with the given object.

Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
ForEach(IConsumer)

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

(Inherited from IIterable)
GetHashCode()

Computes a hash code for this path.

GetName(Int32)

Returns a name element of this path as a Path object.

Iterator()

Returns an iterator over the name elements of this path.

Normalize()

Returns a path that is this path with redundant name elements eliminated.

Of(String, String[])
Of(URI)

Returns a Path by converting a URI.

Register(IWatchService, IWatchEventKind[])

Registers the file located by this path with a watch service.

Register(IWatchService, IWatchEventKind[], IWatchEventModifier[])

Registers the file located by this path with a watch service.

Relativize(IPath)

Constructs a relative path between this path and a given path.

Resolve(IPath)

Resolve the given path against this path.

Resolve(String)

Converts a given path string to a Path and resolves it against this Path in exactly the manner specified by the #resolve(Path) resolve method.

ResolveSibling(IPath)

Resolves the given path against this path's #getParent parent path.

ResolveSibling(String)

Converts a given path string to a Path and resolves it against this path's #getParent parent path in exactly the manner specified by the #resolveSibling(Path) resolveSibling method.

SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
Spliterator()

Creates a Spliterator over the elements described by this Iterable.

(Inherited from IIterable)
StartsWith(IPath)

Tests if this path starts with the given path.

StartsWith(String)

Tests if this path starts with a Path, constructed by converting the given path string, in exactly the manner specified by the #startsWith(Path) startsWith(Path) method.

Subpath(Int32, Int32)

Returns a relative Path that is a subsequence of the name elements of this path.

ToAbsolutePath()

Returns a Path object representing the absolute path of this path.

ToFile()

Returns a File object representing this path.

ToRealPath(LinkOption[])

Returns the <em>real</em> path of an existing file.

ToString()

Returns the string representation of this path.

ToUri()

Returns a URI to represent this path.

UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
ToEnumerable(IIterable)
ToEnumerable<T>(IIterable)

Applies to